public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/51312] New: Wrong interpretation of converted constant expressions (for template arguments and enumerator initializers)
@ 2011-11-26 15:16 tsoae at mail dot ru
  2011-11-26 15:33 ` [Bug c++/51312] " marc.glisse at normalesup dot org
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: tsoae at mail dot ru @ 2011-11-26 15:16 UTC (permalink / raw)
  To: gcc-bugs

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.


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2014-08-07 19:53 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-26 15:16 [Bug c++/51312] New: Wrong interpretation of converted constant expressions (for template arguments and enumerator initializers) tsoae at mail dot ru
2011-11-26 15:33 ` [Bug c++/51312] " marc.glisse at normalesup dot org
2011-11-26 17:32 ` tsoae at mail dot ru
2012-01-30 22:15 ` [Bug c++/51312] [C++0x] Wrong interpretation of converted constant expressions (for " pinskia at gcc dot gnu.org
2012-02-08 20:20 ` pinskia at gcc dot gnu.org
2012-04-29 14:12 ` marc.glisse at normalesup dot org
2014-07-12 19:57 ` paolo.carlini at oracle dot com
2014-07-13  8:54 ` paolo.carlini at oracle dot com
2014-07-13  9:17 ` paolo.carlini at oracle dot com
2014-07-22 10:01 ` glisse at gcc dot gnu.org
2014-07-31 13:26 ` paolo.carlini at oracle dot com
2014-08-06 19:46 ` paolo.carlini at oracle dot com
2014-08-07  0:02 ` paolo.carlini at oracle dot com
2014-08-07 19:52 ` paolo at gcc dot gnu.org
2014-08-07 19:53 ` paolo.carlini at oracle dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).