[cfe-dev] _Generic with __attribute__((overloadable))
Nemanja Ivanovic via cfe-dev
cfe-dev at lists.llvm.org
Tue Aug 30 12:11:07 PDT 2016
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160830/afb0f2ed/attachment.html>
More information about the cfe-dev
mailing list