http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51312
Bug #: 51312
Summary: Wrong interpretation of converted constant expressions
(for template arguments and enumerator initializers)
Classification: Unclassified
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: [email protected]
ReportedBy: [email protected]
GNU C++ 4.7.0 fails to compile the following well-defined code:
struct X
{
constexpr operator int()
{ return true; }
};
template <int>
struct A {};
int main()
{
// error: expected a constant of type 'int', got 'X()'
A<X()>();
// error: enumerator value for 'e' is not an integer constant
enum : int { e = X() };
}
In both cases a converted constant expression of type int is required (see
14.3.2/1/1 and 7.2/5). According to 5.19/3, X() can be used in a context where
a converted constant expression of type int is required.