This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/51312] New: Wrong interpretation of converted constant expressions (for template arguments and enumerator initializers)


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: unassigned@gcc.gnu.org
        ReportedBy: tsoae@mail.ru


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]