From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 84315 invoked by alias); 12 Jul 2017 08:45:46 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 84106 invoked by uid 89); 12 Jul 2017 08:45:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.5 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy= X-HELO: mo4-p00-ob.smtp.rzone.de Received: from mo4-p00-ob.smtp.rzone.de (HELO mo4-p00-ob.smtp.rzone.de) (81.169.146.217) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 12 Jul 2017 08:45:35 +0000 X-RZG-AUTH: :LXoWVUeid/7A29J/hMvvT3ol15ykJcYwR/bcHRirORRW3yMcVao= X-RZG-CLASS-ID: mo00 Received: from [192.168.0.123] (mail.hightec-rt.com [213.135.1.215]) by smtp.strato.de (RZmta 41.1 DYNA|AUTH) with ESMTPSA id e084b6t6C8jPHBT (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA)) (Client did not present a certificate); Wed, 12 Jul 2017 10:45:25 +0200 (CEST) To: gcc-patches Cc: Denis Chertykov From: Georg-Johann Lay Subject: [patch,avr] PR81407: Error if progmem variable needs constructing. Message-ID: Date: Wed, 12 Jul 2017 08:45:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------F6F540CF1EBAF0CF3DD2E5CB" X-IsSubscribed: yes X-SW-Source: 2017-07/txt/msg00578.txt.bz2 This is a multi-part message in MIME format. --------------F6F540CF1EBAF0CF3DD2E5CB Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-length: 403 Hi, if the C++ front-end decides that something will need constructing, it will silently put the stuff into .rodata so that according pgm_read_xxx will read garbage from .progmem. As proposed by Jason, this patch diagnoses such situations. Ok to commit? Johann PR target/81407 * config/avr/avr.c (avr_encode_section_info) [progmem && !TREE_READONLY]: Error if progmem object needs constructing. --------------F6F540CF1EBAF0CF3DD2E5CB Content-Type: text/x-patch; name="pr81407-progmem-construct.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="pr81407-progmem-construct.diff" Content-length: 1254 Index: config/avr/avr.c =================================================================== --- config/avr/avr.c (revision 250093) +++ config/avr/avr.c (working copy) @@ -10380,14 +10380,22 @@ avr_encode_section_info (tree decl, rtx && !DECL_EXTERNAL (decl) && avr_progmem_p (decl, DECL_ATTRIBUTES (decl))) { - // Don't warn for (implicit) aliases like in PR80462. tree asmname = DECL_ASSEMBLER_NAME (decl); varpool_node *node = varpool_node::get_for_asmname (asmname); bool alias_p = node && node->alias; - if (!alias_p) - warning (OPT_Wuninitialized, "uninitialized variable %q+D put into " - "program memory area", decl); + if (!TREE_READONLY (decl)) + { + // This might happen with C++ if stuff needs constructing. + error ("variable %q+D with dynamic initialization put " + "into program memory area", decl); + } + else if (!alias_p) + { + // Don't warn for (implicit) aliases like in PR80462. + warning (OPT_Wuninitialized, "uninitialized variable %q+D put " + "into program memory area", decl); + } } default_encode_section_info (decl, rtl, new_decl_p); --------------F6F540CF1EBAF0CF3DD2E5CB--