[LLVMbugs] [Bug 19276] New: Last scoped name during name lookup may be repeated indefinitely without error

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Mar 28 10:24:31 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=19276

            Bug ID: 19276
           Summary: Last scoped name during name lookup may be repeated
                    indefinitely without error
           Product: clang
           Version: trunk
          Hardware: PC
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: greg at gregfiumara.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

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)"

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140328/78c388a5/attachment.html>


More information about the llvm-bugs mailing list