https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68918

            Bug ID: 68918
           Summary: spurious "invalid use of incomplete type" in trailing
                    return type
           Product: gcc
           Version: 5.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: lucdanton at free dot fr
  Target Milestone: ---

Happens with GCC 5.2.1 and 6.

$ g++-trunk -std=c++14 main.cpp
main.cpp:20:37: error: invalid use of incomplete type 'const struct foo'
     auto e() const -> decltype( this->a() )
                                     ^~

main.cpp:1:8: note: definition of 'struct foo' is not complete until the
closing brace
 struct foo {
        ^~~

main.cpp:20:37: error: invalid use of incomplete type 'const struct foo'
     auto e() const -> decltype( this->a() )
                                     ^~

main.cpp:1:8: note: definition of 'struct foo' is not complete until the
closing brace
 struct foo {
        ^~~

---------- Testcase ----------
struct foo {
    static void a() {}

    // fine
    auto b() const -> decltype( this->a() )
    {}

    // also fine
    template<typename X>
    auto c() -> decltype( this->a() )
    {}

    // even more fine
    template<typename X>
    auto d() const -> decltype( a() )
    {}

    // error: invalid use of incomplete type 'const struct foo'
    template<typename X>
    auto e() const -> decltype( this->a() )
    {}
};

int main()
{
}

Reply via email to