c++ - Different behaviour between Clang and GCC when performing qualified name lookup -


consider following program:

#include <iostream>  namespace n {     int j = 1; }  namespace m {     typedef int n;     void f() {         std::cout << n::j << std::endl;     } }  int main() { m::f(); } 

compiling clang gives following compiler error:

prog.cc:10:22: error: 'n' (aka 'int') not class, namespace, or enumeration     std::cout << n::j << std::endl;                  ^ 1 error generated. 

gcc not give compiler error. i'm trying figure out compiler should file bug report for. compiler has correct behaviour , why (references c++ standard)?

wandbox - clang: http://melpon.org/wandbox/permlink/s0hkoxcfpgq5asmj

wandbox - gcc: http://melpon.org/wandbox/permlink/i2kol3qtbvucjvbz

clang correct on one. quoting c++11, 3.4.3/1 [basic.lookup.qual]:

... if :: scope resolution operator in nested-name-specifier not preceded decltype-specifier, lookup of name preceding :: considers namespaces, types, , templates specializations types. if name found not designate namespace or class, enumeration, or dependent type, program ill-formed.

per clause, types supposed considered during lookup, typedef n should found. , since not designate namespace, class, enumeration, or dependent type, program ill-formed.


Comments

Popular posts from this blog

php - Zend Framework / Skeleton-Application / Composer install issue -

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -