Fix crash with UniqueExternalLinkage in extern "C" contexts

Richard Smith richard at metafoo.co.uk
Mon Mar 11 23:21:26 PDT 2013


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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130311/03e8f30c/attachment.html>


More information about the cfe-commits mailing list