This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: typedef & constructor bug
- To: Jos dot vandenOever at fenk dot wag-ur dot nl
- Subject: Re: typedef & constructor bug
- From: Alexandre Oliva <oliva at lsd dot ic dot unicamp dot br>
- Date: 08 Mar 2000 06:42:56 -0300
- Cc: gcc-bugs at gcc dot gnu dot org
- References: <38C61ECD.A024145D@fenk.wag-ur.nl>
On Mar 8, 2000, Jos van den Oever <Jos.vandenOever@fenk.wag-ur.nl> wrote:
> typedef char * Ptr;
> Text(const Ptr);
Please note that this is `char *const', not `char const*', i.e., it is
Ptr that is const, not the pointed-to chars. This explains why GCC
can't construct a Text from the `const char *' in:
> useText((i>0) ? "ok" : "not ok");
However, because a string literal can be converted to non-const
`char*', if the surrounding context expects a `char*', this also
succeeds:
> useText((i>0) ? "ok" : Text("ok"));
It's equivalent to:
useText((i>0) ? Text((char*)"ok") : Text((char*)"ok"));
--
Alexandre Oliva http://www.ic.unicamp.br/~oliva/ Enjoy Guaranį
Cygnus Solutions, a Red Hat company aoliva@{redhat, cygnus}.com
Free Software Developer and Evangelist CS PhD student at IC-Unicamp
oliva@{lsd.ic.unicamp.br, gnu.org} Write to mailing lists, not to me