[Bug c++/57502] New: Expected error "Declaration doesn't declare anything", but code compiles fine for user-defined class with using decltype, but not with built-in types.

0coming.soon at gmail dot com gcc-bugzilla@gcc.gnu.org
Sun Jun 2 03:54:00 GMT 2013


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57502

            Bug ID: 57502
           Summary: Expected error "Declaration doesn't declare anything",
                    but code compiles fine for user-defined class with
                    using decltype, but not with built-in types.
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: trivial
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: 0coming.soon at gmail dot com

I expected error for line "decltype(Foo{});" like an error for other two lines,
but compiler doesn't throw it:

$ cat main.cpp
class Foo
{

};

int main()
{
    decltype(Foo{});  // compiles
    Foo;              // fails as expected
    decltype(int{});  // fails as expected

    return 0;
}

$ g++ -Wall -Wextra -std=c++11 main.cpp
main.cpp: In function ‘int main()’:
main.cpp:9:5: error: declaration does not declare anything [-fpermissive]
     Foo;              // fails as expected
     ^
main.cpp:10:5: error: declaration does not declare anything [-fpermissive]
     decltype(int{});  // fails as expected
     ^

gcc version 4.8.0 20130502 (prerelease) (GCC)


More information about the Gcc-bugs mailing list