d: Merge upstream dmd, druntime 4ca4140e58, phobos 454dff14d.
[official-gcc.git] / gcc / testsuite / gdc.test / runnable / test18472.d
bloba571b08cfd25fdc837cb779c7598a23e75cf9747
1 /* REQUIRED_ARGS: -betterC
2 */
4 /*******************************************/
5 // https://issues.dlang.org/show_bug.cgi?id=18472
6 // https://github.com/dlang/dmd/pull/14676
8 @nogc nothrow pure:
9 immutable(Char)[] format(Char, Args...)(in Char[] fmt, Args args)
12 if (__ctfe)
14 auto data2 = new char[5];
15 auto data = new Data2;
17 auto data3 = new Data2;
19 data2 = cast(char[]) "test2";
20 return data2;
22 else
24 return "test";
28 extern(C) void main()
30 static assert(getData() == "test");
31 static assert("%s %s".format("test", "test") == "test2", "Not working");
32 assert("%s %s".format("test", "test") == "test", "%s %s".format("test", "test"));
33 assert(getData() == "test2", getData());
36 string getData()
38 if (__ctfe)
40 auto data2 = new ubyte[5];
41 auto data = new Data2;
42 return "test";
44 else
46 return "test2";
50 private struct Data2
52 size_t capacity;