https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96207
            Bug ID: 96207
           Summary: GCC accepts "delete" function definition inside a
                    class member function
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Keywords: accepts-invalid
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: haoxintu at gmail dot com
  Target Milestone: ---

Hi, all.

This code, test.cc, is an invalid code, GCC compiles it well, while other
mainstream compiles (clang,icc,and msvc) all reject it.

$cat test.cc
class A {
    void foo1 () {    
        void foo2 () = delete  ;
    }
};

$g++ -c test.cc
test.cc: In member function ‘void A::foo1()’:
test.cc:3:20: warning: declaration of ‘void foo2()’ has ‘extern’ and is
initialized
    3 |         void foo2 () = delete  ;
      |                    ^

GCC only emits a warning message (I also doubt that the meaning of this
message) and then accepts it.

Every Clang version from 6.x onwards behaves the same.

Thanks,
Haoxin

Reply via email to