[Bug c++/76577] Tree folding may remove UB which causes invalid constexpr function calls to be accepted

marxin at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sun Aug 14 19:04:00 GMT 2016


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);
                      ^


More information about the Gcc-bugs mailing list