This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c++/10187: string literal converted to non-const `char[]' when used as argument to function template
- From: bangerth at dealii dot org
- To: bsamwel at xs4all dot nl, gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, jtv at xs4all dot nl, bsamwel at xs4all dot nl, nobody at gcc dot gnu dot org
- Date: 21 Mar 2003 23:24:53 -0000
- Subject: Re: c++/10187: string literal converted to non-const `char[]' when used as argument to function template
- Reply-to: bangerth at dealii dot org, bsamwel at xs4all dot nl, gcc-bugs at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, jtv at xs4all dot nl, bsamwel at xs4all dot nl, nobody at gcc dot gnu dot org, gcc-gnats at gcc dot gnu dot org
Synopsis: string literal converted to non-const `char[]' when used as argument to function template
State-Changed-From-To: open->closed
State-Changed-By: bangerth
State-Changed-When: Fri Mar 21 23:24:53 2003
State-Changed-Why:
By 2.13.4.1,
An ordinary string literal has type "array of n const
char" and static storage duration (_basic.stc_), where n is the size
of the string as defined below, and is initialized with the given
characters.
To get the effect you want, declare a function
template <int N>
int foo (const char (&x)[N])
{}
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=10187