C++ Issue with const char * on strchr
Jochen Schmitt
Jochen at herr-schmitt.de
Tue Mar 10 20:42:24 UTC 2009
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Conrad Meyer schrieb:
>
> const char *str1, str2; str2 = strchr(str1, 'a');
>
> But str2 must be a const char *.
>
> Maybe I am wrong, I am not very familiar with C++.
>
> Regards, My understanding is you can do something like this:
I am doing something like this
char *str2;
const char *str1;
str2 = strchr(str1, 'a'); // This fails on gcc-4.4
When I write
char *str2;
const char *str1;
char *temp = const_cast<char *>(str1);
str2 = strchr(temp,'a') // This works
Because this issue occurs only on gcc-4.4, I want to ask: is this
a bug or a feature?
Best Regards:
Jochen Schmitt
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org
iEYEARECAAYFAkm20JsACgkQT2AHK6txfgzuoQCfRAMhKyGcmoj2I8fwDRICTaaC
ePcAn3tGbFwJ8XsKG4KYZ3uUHZ50EDcS
=fGas
-----END PGP SIGNATURE-----
More information about the fedora-devel-list
mailing list