[Bug c++/55513] [4.7/4.8 Regression] Incorrect snprintf folding when building with -std=c++0x
aldyh at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Dec 6 21:06:00 GMT 2012
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55513
--- Comment #8 from Aldy Hernandez <aldyh at gcc dot gnu.org> 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))
More information about the Gcc-bugs
mailing list