<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Last scoped name during name lookup may be repeated indefinitely without error"
   href="http://llvm.org/bugs/show_bug.cgi?id=19276">19276</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Last scoped name during name lookup may be repeated indefinitely without error
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>MacOS X
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>greg@gregfiumara.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The last scope when referring to a name can be repeated indefinitely without
encountering an error. For instance, "class Name {};" may be instantiated by
"Name::Name::Name::Name name;". g++ 4.8+ (at least) catches this as an error.

Sample code follows. Note that clang++ does catch the error in a typedef, but
not in a using declaration or anywhere else that I've seen.

#include <iostream>

namespace Foo
{
    namespace Bar
    {
        class Baz
        {
        public:
            Baz() {}
            ~Baz() {}
            void sayHello() {std::cout << "Hello\n";}
        };
    }
}

class Name
{
public:
    Name() {}
    ~Name() {}
    void sayHello() {std::cout << "Hello\n";}
};

/* These should fail, only typedef does */
//typedef Name::Name::Name::Name::Name::Name::Name NameAlias;
//using NameAlias = Name::Name::Name::Name::Name::Name::Name;

int
main()
{
    Foo::Bar::Baz baz1;        /* Okay */
    baz1.sayHello();

    Foo::Bar::Baz::Baz baz2;    /* This should fail */
    baz2.sayHello();

    Name name1;            /* Okay */
    name1.sayHello();

    Name::Name::Name name2;     /* This should fail */
    name2.sayHello();

    return (0);
}

clang++ compilation doesn't show the error and assumes what I meant
$ clang++ -Wall -Wextra -Weverything -pedantic t.cxx 


g++ does not
$ g++-4.8 -Wall -Wextra -pedantic t.cxx 
t.cxx:35:2: error: 'Foo::Bar::Baz::Baz' names the constructor, not the type
t.cxx:35:25: error: statement cannot resolve address of overloaded function
t.cxx:41:2: error: 'Name::Name' names the constructor, not the type
t.cxx:41:24: error: statement cannot resolve address of overloaded function


Tested 2014-03-28 13:28, OS X 10.9.2 with both "Apple LLVM version 5.1
(clang-503.0.38)" and "clang version 3.5.0 (trunk 205007)." For reference,
g++-4.8 (above) is "gcc version 4.8.2 (MacPorts gcc48 4.8.2_0)"</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>