[cfe-dev] _Generic with __attribute__((overloadable))
Nemanja Ivanovic via cfe-dev
cfe-dev at lists.llvm.org
Tue Aug 30 12:52:22 PDT 2016
OK, thank you.
Filed https://llvm.org/bugs/show_bug.cgi?id=30201
On Tue, Aug 30, 2016 at 9:34 PM, Aaron Ballman <aaron at aaronballman.com>
wrote:
> On Tue, Aug 30, 2016 at 3:11 PM, Nemanja Ivanovic via cfe-dev
> <cfe-dev at lists.llvm.org> wrote:
> > Rather than opening a bug, I thought I'd check if this is supposed to
> work
> > (given that the overloadable attribute is an extension).
> >
> > Should this compile and have the expected semantics (i.e. call the int
> > version):
> >
> > int __attribute__((overloadable)) test (int);
> > double __attribute__((overloadable)) test (double);
> > char testc(char);
> >
> > #define testm(X) \
> > _Generic ((X), \
> > char : testc, \
> > default: test) (X)
> >
> >
> > int foo() {
> > return testm(4);
> > }
> >
> > It appears that the _Generic macro triggers overload resolution of some
> sort
> > which resolves the call to yet another overloaded function. So we hit an
> > UNREACHABLE in Sema::FixOverloadedFunctionReference.
> >
> > If the argument in the call is replaced with a char value, there is no
> > crash.
> >
> > In any case, presumably this crash behaviour should perhaps be improved
> with
> > a diagnostic.
>
> The crash is definitely a bug, and we should either fix it with a
> diagnostic, or handle the overloadable attribute more sensibly. Can
> you file this as a bug (https://llvm.org/bugs)?
>
> Thanks!
>
> ~Aaron
>
> >
> > _______________________________________________
> > cfe-dev mailing list
> > cfe-dev at lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160830/cb2761f0/attachment.html>
More information about the cfe-dev
mailing list