From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23343 invoked by alias); 6 Dec 2012 21:06:43 -0000 Received: (qmail 23287 invoked by uid 48); 6 Dec 2012 21:06:30 -0000 From: "aldyh at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/55513] [4.7/4.8 Regression] Incorrect snprintf folding when building with -std=c++0x Date: Thu, 06 Dec 2012 21:06: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-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: aldyh at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: aldyh at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.7.3 X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 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 X-SW-Source: 2012-12/txt/msg00611.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55513 --- Comment #8 from Aldy Hernandez 2012-12-06 21:06:29 UTC --- After Jason's patch here (trunk@177066): PR c++/49813 * semantics.c (potential_constant_expression_1): Allow any builtin. (morally_constexpr_builtin_function_p): Remove. It seems we return true for any built-in in potential_constant_expression_1. This means that check_initializer->store_init_value->maybe_constant_init will chop off the built-in side of a COMPOUND_EXPR when setting a DECL_INITIAL, transforming: (COMPOUND_EXPR (CALL_EXPR built-in) INTEGER_CST) into INTEGER_CST Since potential_constant_expression_1 returns true for any built-in, we end up removing even a __builtin_exit from code like this: const int t = (__builtin_exit(0), 777); Jason, is this by design? Should we not limit the conditional here further?: /* Allow any built-in function; if the expansion isn't constant, we'll deal with that then. */ && !is_builtin_fn (fun))