[Bug c++/87381] clang 6.0 will compile this constexpr construct, but gcc 8.2.1 will not.
eric-bugs at omnifarious dot org
gcc-bugzilla@gcc.gnu.org
Fri Sep 21 18:25:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87381
--- Comment #5 from eric-bugs at omnifarious dot org ---
Here is the problem, reduced to the simplest expression I could make:
-----
template <int x>
struct test_template {
static int size() { return x; }
};
constexpr int ce_strlen(char const *s)
{
int i = 0;
while (s[i]) ++i;
return i;
}
int joe()
{
constexpr int plen = ce_strlen(__PRETTY_FUNCTION__); // This works
test_template<plen> a; // This declaration is valid.
test_template<ce_strlen(__PRETTY_FUNCTION__)> b; // But this doesn't work?!
return a.size() + b.size();
}
------
Either the declaration/initialization of both plen and b should fail, or they
should both succeed. It makes no sense for one to work and the other to not.
More information about the Gcc-bugs
mailing list