Compiling GCC With a C++ Compiler (g++)
Geoffrey Keating
geoffk@apple.com
Wed Oct 13 20:39:00 GMT 2004
On 12/10/2004, at 8:42 PM, Gabriel Dos Reis wrote:
> The code in build_string
>
> memset (s, 0, sizeof (struct tree_common));
> TREE_SET_CODE (s, STRING_CST);
> TREE_STRING_LENGTH (s) = len;
> memcpy ((char *) TREE_STRING_POINTER (s), str, len);
> ((char *) TREE_STRING_POINTER (s))[len] = '\0';
>
> is trying to do similar thing, but it is undefined behaviour.
>
> [#5] If an attempt is made to modify an object defined with
> a const-qualified type through use of an lvalue with non-
> const-qualified type, the behavior is undefined.
The object here is '*s', which was not defined with a const-qualified
type. It's not defined with any type at all, it was allocated through
malloc which is not a typed interface. (It would be different if it
was allocated through 'new', but we do not have new in C.)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2408 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc/attachments/20041013/998b0cba/attachment.p7s>
More information about the Gcc
mailing list