[cfe-dev] Simple c++ sample not building with clang++

Romain Pechayre rpechayr at gmail.com
Mon Aug 23 07:12:51 PDT 2010


Thank you Douglas,

In the meantime I had the idea to try the latest SVN and it worked ! Sorry
that I did not post my issue was solved.

Romain


On Mon, Aug 23, 2010 at 4:06 PM, Douglas Gregor <dgregor at apple.com> wrote:

>
> On Aug 23, 2010, at 4:00 AM, Romain Pechayre wrote:
>
> Hello, please consider the following simple c++ code:
> % cat Main.cc
> //first alias
> namespace original_namespace {}  // decl 1
> namespace client_namespace {
>   namespace alias_ns = original_namespace;
> }
>
> //second alias
> namespace original_namespace {} //decl 2
> namespace client_namespace {
>   namespace alias_ns = original_namespace;
> }
>
> This does not build with clang++ and does build with g++
> . I get the following diagnosis:
> Main.cc:16:11: error: redefinition of 'alias_ns' as different kind of
> symbol
>
> namespace alias_ns = original_namespace;
>                   ^
> Main.cc:16:1: note: previous definition was here:
> namespace alias_ns = original_namespace;
> ^
>
> Of course this is a silly example, but I came across this when some similar
> code was included again and again from different source files. I have put
> this into a simple single file to see if I was still getting the problem,
> and yes.
>
> Even more surprising is when you comment  decl2 of namespace
> original_namespace, no error ! I cannot understand why. Then I thought that
> maybe clang was mispointing the error that was in the second declaration of
> original_namespace. It is not the case, as only commenting the second alias
> instruction and keeping decl1 works.
>
> I am using clang and llvm 2.7 (not svn)
>
>
> That was a bug in Clang 2.7, which has already been fixed on mainline. In
> general, you should not use Clang 2.7 for C++ code. Top-of-tree in
> Subversion is far, far better at handling C++.
>
> - Doug
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20100823/d6ea0713/attachment.html>


More information about the cfe-dev mailing list