[cfe-users] compiler bug or language feature?

Richard Smith richard at metafoo.co.uk
Tue Oct 8 11:08:23 PDT 2013


You need to write

  m_sptr.SmartPtrType<T>::~SmartPtrType*<T>*();

Per 3.4.3/6, "in a qualified-id of the form nested-name-specifier[opt]
class-name::~class-name, the second class-name is looked up in the same
scope as the first". So you can't use the injected-class-name after the ~,
because it's not visible.

On Tue, Oct 8, 2013 at 10:05 AM, Daniel Schwalbe <dansch491 at gmail.com>wrote:

>  When I add the 'template' keyword as suggested clang gives me the very
> same error. g++ still eats it without problem.
>
> Am 08.10.2013 18:23, schrieb David Blaikie:
>
>
>
>
> On Tue, Oct 8, 2013 at 8:36 AM, Daniel Schwalbe <dansch491 at gmail.com>wrote:
>
>> Hi,
>>
>> I don't know if I encountered a compiler bug in clang 3.3 or if this is
>> one of the many subtle c++ exceptional cases:
>>
>> When I try to compile the attached file (using: clang++ -std=c++11
>> test.cpp) I receive a compiler error:
>>
>> "test.cpp:15:42: error: identifier 'SmartPtrType' in object destruction
>> expression does not name a type
>>  ~SmartUnion() {m_sptr.SmartPtrType<T>::~SmartPtrType(); }"
>>
>> g++ compiles the file without problem.
>>
>> clang compiles it, too, if I explicitly introduce a typedef for
>> SmartPtrType<T> and call this typedef name instead:
>>
>> typedef SmartPtrType<T> smartptr_type;
>> ~SmartUnion() {m_sptr.smartptr_type::~smartptr_type(); }
>>
>> Is this a subtle language feature or a compiler bug?
>
>
>  I believe this is a language feature because the expression is ambiguous
> if m_sptr is type dependent (which I assume it is)
>
> The other solution, rather than introducing a typedef, is to use the
> 'template' keyword:
>
> ~SmartUnion() {m_sptr.template SmartPtrType<T>::~SmartPtrType(); }
>
>
>>
>>
>> Daniel
>>
>>
>>
>>
>> _______________________________________________
>> cfe-users mailing list
>> cfe-users at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-users
>>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20131008/d9ce7bdf/attachment.html>


More information about the cfe-users mailing list