overloadable + C string literal looks like a bug, seeking confirmation

Just opened https://bugs.llvm.org/show_bug.cgi?id=49978 with the default CC as I’m not sure who does C front end stuff. Seeking confirmation that this is considered a bug by other people.

attribute((overloadable) void func(char *);

attribute((overloadable) void func(const char *);
void call(void)
{
func(“ambiguous”);
}

I think “ambiguous” should decay to a char* and pick the char* overload. Something of an edge case because “literals” have different types between C and C++, and overloadable is an extension anyway.

Thanks

Just opened https://bugs.llvm.org/show_bug.cgi?id=49978 with the default CC as I'm not sure who does C front end stuff. Seeking confirmation that this is considered a bug by other people.

__attribute__((overloadable) void func(char *);
__attribute__((overloadable) void func(const char *);
void call(void)
{
  func("ambiguous");
}

I think "ambiguous" should decay to a char* and pick the char* overload. Something of an edge case because "literals" have different types between C and C++, and overloadable is an extension anyway.

FWIW, I think this is a bug. I think in C, this should pick the char *
overload because that's the type of the string literal.

~Aaron

Just opened https://urldefense.com/v3/https://bugs.llvm.org/show_bug.cgi?id=49978;!!A4F2R9G_pg!KQoRD0xNIzyyey_uDcossBECcs23GC4qIW4UypD3pfxdIgQCRqSZ7a39rV2jlHB5$ with the default CC as I'm not sure who does C front end stuff. Seeking confirmation that this is considered a bug by other people.

__attribute__((overloadable) void func(char *);
__attribute__((overloadable) void func(const char *);
void call(void)
{
   func("ambiguous");
}

I think "ambiguous" should decay to a char* and pick the char* overload. Something of an edge case because "literals" have different types between C and C++, and overloadable is an extension anyway.

FWIW, I think this is a bug. I think in C, this should pick the char *
overload because that's the type of the string literal.

Agreed, and that would be consistent with _Generic:

void func_nonconst(char *);
void func_const(const char *);
#define func(X) \
_Generic((X), \
char*: func_nonconst, \
const char*: func_const)(X)
void call(void)
{
func("not ambiguous; calls func_nonconst()");
}

Tom.