% cat strlit-to-void-ptr.c
extern void setValue(void * value);
int main(void) { setValue("String 1");
char * s2 = "String 2"; setValue(s2);
return 0; }
% g++ -c strlit-to-void-ptr.c strlit-to-void-ptr.c: In function `int main()': strlit-to-void-ptr.c:6: error: invalid conversion from `const void*' to `void*'
It seems to me that the conversion of 'const char *' to 'char *'
specified in ISO 14882 4.2 ¶2 should be applied prior to the conversion of 'char *' to 'void *' spec'd in 4.10. I believe this is what allows the declaration and use of s2 to compile without error.
Also, we don't get a warning for this practice with any of the other 4 compilers we use, which doesn't prove anything but does provide some support. Are all of those compilers in fact non-compliant or is this a g++ bug?
-- Jack Marr (marr@xxxxxxx) UGS -- Development Environment Tools Cypress, CA "Ite Ursi"