[EMAIL PROTECTED] writes: > > > >(To be fair at this, the compiler _should_ have given a warning or > >error for your code, because you're initializing a 'char *' pointer > >from a 'const char *' pointer. Discarding 'const' without an explicit > >cast is a programming error.) > > > Except that the type of a "string literal" wasn't a "const char *" as > the standard claims the elements of the array have "type char". > > Modifying the chars merely gives undefined behaviour (which is in keeping > with the fact that they are not const char *)
True ... except that, as I see it, the compiler walks you directly into the path of an oncoming train for no obvious reason. It's not just undefined, but in this case implementation defined behavior. The implementation is offering const string literals, so it's being disingenuous (at best) by letting you use them in a writable context. -- James Carlson, Solaris Networking <[EMAIL PROTECTED]> Sun Microsystems / 1 Network Drive 71.232W Vox +1 781 442 2084 MS UBUR02-212 / Burlington MA 01803-2757 42.496N Fax +1 781 442 1677 _______________________________________________ opensolaris-code mailing list [email protected] http://mail.opensolaris.org/mailman/listinfo/opensolaris-code
