[cfe-dev] constexpr static methods

Eli Friedman eli.friedman at gmail.com
Thu Jan 12 21:11:56 PST 2012


On Thu, Jan 12, 2012 at 5:46 PM, Miles Bader <miles at gnu.org> wrote:
> Hi, with the following prog:
>
>   class X
>   {
>     X ();
>     constexpr static int foo () { return 3; }
>   };
>
> compiling with options "-c -std=c++11", I get this error from clang++:
>
>   clang++ -c -std=c++11 /tmp/x.cc
>   /tmp/x.cc:4:24: error: non-literal type 'X' cannot have constexpr members
>     constexpr static int foo () { return 3; }
>                          ^
>   /tmp/x.cc:1:7: note: 'X' is not literal because it is not an aggregate and has
>         no constexpr constructors other than copy or move constructors
>   class X
>         ^
>   1 error generated.
>
> Is this correct?  Such an error would make sense for a non-static
> method, but it seems pretty weird for a static method...

No; fixed in r148090.

-Eli




More information about the cfe-dev mailing list