c++11 - Contradictory results between GCC and clang related to [basic.link]/7 in the C++ Standard -


this snippet compiles in clang,

namespace {     void f() {         void g();         g();     } }  void a::g() { } 

but gcc accepts code if g defined inside namespace a follows:

namespace {     void f() {         void g();         g();     }     void g() {} } 

but believe there's nothing in [basic.link]/7 disallowing first snippet above.

[basic.link]/p7, emphasis mine:

when block scope declaration of entity linkage not found refer other declaration, entity member of innermost enclosing namespace. however such declaration not introduce member name in namespace scope.

[namespace.memdef]/p2, emphasis mine:

members of named namespace can defined outside namespace explicit qualification (3.4.3.2) of name being defined, provided entity being defined declared in namespace , definition appears after point of declaration in namespace encloses declaration’s namespace.

gcc correct. first snippet ill-formed.


Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -