June 28, 2005 [bug] string literals should be const | ||||
---|---|---|---|---|
| ||||
According section 2.13.4 of the standard, a string literal has type "array of n const char". So this should work: template <class T> void test(T x) { char const* y; T z = y; } int main() { test("xxxx"); } Although, section 4.2 specifies that a conversion is allowed to a non-const pointer. So this is still allowed: char* p = "abc"; But that's deprecated according to Annex D. It's also mentioned in C.1.1. Daniel |
Copyright © 1999-2021 by the D Language Foundation