Fix crash with UniqueExternalLinkage in extern "C" contexts

Richard Smith richard at metafoo.co.uk
Mon Mar 11 23:22:41 PDT 2013


On Mon, Mar 11, 2013 at 11:21 PM, Richard Smith <richard at metafoo.co.uk>wrote:

> On Mon, Mar 11, 2013 at 7:01 PM, Rafael EspĂ­ndola <
> rafael.espindola at gmail.com> wrote:
>
>> On 11 March 2013 21:02, Rafael EspĂ­ndola <rafael.espindola at gmail.com>
>> wrote:
>> > Clang currently hits the assert in GetGVALinkageForVariable when
>> compiling
>> >
>> > namespace {
>> >   struct X {};
>> > }
>> > extern "C" {
>> >   X b = X();
>> > }
>> >
>> > The attached patch fixes it by propagating the linkage to variables,
>> > even if they are extern "C". This seems consistent with how we handle
>> > other interactions of language linkage and non-external linkage.
>>
>> Sorry. Reading [basic.link] again I now think that the assert is just
>> bogus. The standard talks about entities with C language linkage (and
>> therefore external linkage) whose type has no linkage. It is
>> reasonable to also accept types that have non-external linkage.
>>
>> The attached patch fixes it.
>
>
> LGTM. We're allowed (but not required) to emit an external symbol in this
> case; the lack of an external symbol doesn't seem like something worth
> asserting over.
>

... and by "in this case" I mean for the remaining cases of the assert: a
non-extern-"C" external linkage variable with an unique-extern type. (In
the extern "C" case, we must emit an external symbol.)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130311/0419401a/attachment.html>


More information about the cfe-commits mailing list