From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32508 invoked by alias); 18 Nov 2014 11:26:23 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 32425 invoked by uid 48); 18 Nov 2014 11:26:18 -0000 From: "ktietz at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/63904] ICE when accessing array member of constexpr struct Date: Tue, 18 Nov 2014 11:26:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: ktietz at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-11/txt/msg01628.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63904 Kai Tietz changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |ktietz at gcc dot gnu.org --- Comment #1 from Kai Tietz --- It seems to be related to constexpr.c:cxx_eval_vec_init_1 function. The line ' int max = tree_to_shwi (array_type_nelts (atype));' there should be changed into 'int max = (int) tree_to_uhwi (array_type_nelts (atype));'. Issue is that array_type_netls returns size_type node (which is unsigned) with UHWI_MAX as value. Means that on conversions the value won't fit into shwi. By reading value as unsigned and then later on casting it to signed (btw shouldn't we use here instead HOST_WIDE_INT?), we solve this issue.