fork download
  1. #include <iostream>
  2.  
  3. struct widget
  4. {
  5. struct baz { explicit baz() { std::cout << "constructor\n"; } };
  6. static void baz() { std::cout << "function\n"; }
  7. };
  8.  
  9. int main()
  10. {
  11. typename widget::baz(); // g++ bugs
  12. widget::baz();
  13. return 0;
  14. }
  15. // whereas clang gives:
  16. // clang++ -std=c++11 -O0 -Wall -Wextra -pedantic -pthread main.cpp && ./a.out
  17. // main.cpp:11:22: error: typename specifier refers to non-type member 'baz' in 'widget'
  18. // typename widget::baz();
  19. // ~~~~~~~~~~~~~~~~~^~~
  20. //
  21. // main.cpp:6:17: note: referenced member 'baz' is declared here
  22. // static void baz() { std::cout << "function\n"; }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
constructor
function