[Issue 19002] __FUNCTION__ and __PRETTY_FUNCTION__ are not C string literals
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Jun 27 15:17:15 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=19002
--- Comment #2 from Steven Schveighoffer <schveiguy at yahoo.com> ---
No, this is not expected. I can use printf with a string literal, and it works,
even if it's via an enum, or some const folding. The compiler implicitly can
cast a string literal to a const(char*), otherwise using C functions with
string literals would be painful.
For example:
printf("hello" ~ "\n"); // ok
enum x = "hello";
printf(x); // ok
enum y = __FUNCTION__;
printf(y); // nope
enum z = ctfeFunction();
printf(z); // nope
I think all of these should work, they are all string literals, and should be 0
terminated.
--
More information about the Digitalmars-d-bugs
mailing list