Compiling GCC With a C++ Compiler (g++)
Geoffrey Keating
geoffk@apple.com
Wed Oct 13 21:16:00 GMT 2004
On 13/10/2004, at 8:23 AM, Dave Korn wrote:
>> -----Original Message-----
>> From: Joseph S. Myers
>> Sent: 13 October 2004 15:10
>
>> Without "restrict" the only relevant undefined behavior is if
>> the object
>> is *defined* with qualified type (6.7.3#5). This can apply
>> with static or
>> automatic storage duration declarations such as
>>
>> struct { const char x } y = { z };
>>
>> but cannot apply to an object of allocated storage duration.
>
> Huh? Are you saying that in:
>
> typedef struct { const char x } AA;
>
> AA *py1, py2;
> AA y1 = { z };
>
> py1 = malloc (sizeof *py2);
> py2 = &y1;
>
> it is valid to say
>
> *(char *)(&py1->x) = '?';
>
> but not valid to say
>
> *(char *)(&py2->x) = '?';
Yes, that sounds right.
As a simpler example, given
static const int x = 3;
static int y = 4;
it is valid to say
*(int *)(const int *)&y = 4;
but not
*(int *)(const int *)&x = 4;
-------------- 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/85b5b109/attachment.p7s>
More information about the Gcc
mailing list