c++ - [bug] string literals should be const
- Daniel James (17/17) Jun 28 2005 According section 2.13.4 of the standard, a string literal has type
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
Jun 28 2005








Daniel James <daniel calamity.org.uk>