[Bug c++/87386] [8/9 Regression] Error message for static_assert show wrong range

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Sep 21 21:25:00 GMT 2018


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87386

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2018-09-21
     Ever confirmed|0                           |1

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Proper testcase that actually compiles:

#include <type_traits>
static_assert(std::is_same<int, long>::value,"eee");

87386.cc:2:15: error: static assertion failed: eee
2 | static_assert(std::is_same<int, long>::value,"eee");
  |           



Reduced testcase without header dependencies:

namespace foo {
  template<typename> struct test { static constexpr bool value = false; };
}
static_assert(foo::test<int>::value, "eee");

87386.cc:4:15: error: static assertion failed: eee
4 | static_assert(foo::test<int>::value, "eee");
  |               ^~~


This is a regression, as GCC 7 highlighted the keyword 'static_assert' instead,
which makes more sense than just the first token of the condition:

87386.cc:4:1: error: static assertion failed: eee
 static_assert(foo::test<int>::value, "eee");
 ^~~~~~~~~~~~~


More information about the Gcc-bugs mailing list