[Bug c++/48531] [C++0x][SFINAE] Hard errors with arrays of unknown bound
daniel.kruegler at googlemail dot com
gcc-bugzilla@gcc.gnu.org
Thu Apr 14 23:00:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48531
--- Comment #4 from Daniel Krügler <daniel.kruegler at googlemail dot com> 2011-04-14 23:00:05 UTC ---
(In reply to comment #3)
Here is a minimalistic example that provokes the same error. The essence is,
that the construction expression is evaluated combined with another
construction or destruction expression in a single (constant) expression. The
other expressions seems not relevant, it can even be the same expression, like
here:
//-------------------
template<class T,
class = decltype(T())
>
char f(int);
template<class>
double f(...);
struct B2 {
B2(...);
};
constexpr bool b = sizeof(f<B2[1]>(0)) == 1 && sizeof(f<B2[1]>(0)) == 1;
//-------------------
"main.cpp:13:37: internal compiler error: in build_value_init_noctor, at
cp/init.c:455"
Another example case is, when we combine a destructor expression with a
constructor expression like this (Note that B1 is a slightly differently here):
template<class T,
class = decltype(T())
>
char f(int);
template<class>
double f(...);
template<class T>
T&& create();
template<class T,
class = decltype(create<T&>().~T())
>
char g(int);
template<class>
double g(...);
template<class... T>
struct B1 {
B1(T...);
};
constexpr bool b = sizeof(g<B1<>[1]>(0)) == 1 && sizeof(f<B1<>[1]>(0)) == 1;
This gives exactly the same error:
"main.cpp:31:69: internal compiler error: in build_value_init_noctor, at
cp/init.c:455"
In addition to the ICE the new code gives incorrect results for an array with
known bounds of type with deleted d'tor. Given the same f as defined above
(testing for default construction):
struct D { ~D() = delete; };
static_assert(sizeof(f<D[1]>(0)) != 1, "Error");
the static assertion fires.
More information about the Gcc-bugs
mailing list