This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/76577] Tree folding may remove UB which causes invalid constexpr function calls to be accepted
- From: "marxin at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 14 Aug 2016 19:03:37 +0000
- Subject: [Bug c++/76577] Tree folding may remove UB which causes invalid constexpr function calls to be accepted
- Authentication-results: sourceware.org; auth=none
- Auto-submitted: auto-generated
- References: <bug-76577-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=76577
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |accepts-invalid
Status|UNCONFIRMED |NEW
Last reconfirmed| |2016-08-14
CC| |marxin at gcc dot gnu.org
Ever confirmed|0 |1
--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
The code snippet is accepted by all revisions that support c++11 (4.7.0).
clang 3.8.0 shows:
pr76577.cpp:7:15: error: constexpr variable 'bar' must be initialized by a
constant expression
constexpr int bar = foo (-5);
^ ~~~~~~~~
pr76577.cpp:4:14: note: negative shift count -5
return ((1 << a) & 1) == 0;
^
pr76577.cpp:7:21: note: in call to 'foo(-5)'
constexpr int bar = foo (-5);
^
1 error generated.
and ICC 15.0.1:
pr76577.cpp(7): error: function call must have a constant value in a constant
expression
constexpr int bar = foo (-5);
^