Liste des Groupes | Revenir à c arch |
On Fri, 13 Sep 2024 21:39:39 +0000, Thomas Koenig wrote:
>Michael S <already5chosen@yahoo.com> schrieb:>On Fri, 13 Sep 2024 04:12:21 -0700>
Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:
>Michael S <already5chosen@yahoo.com> writes:>>struct {>
char x[8]
int y;
} bar;
bar.y = 0; bar.x[8] = 42;
>
IMHO, here behavior should be fully defined by implementation. And
in practice it is. Just not in theory.
Do you mean union rather than struct? And do you mean bar.x[7]
rather than bar.x[8]? Surely no one would expect that storing
into bar.x[8] should be well-defined behavior.
>
If the code were this
>
union {
char x[8];
int y;
} bar;
bar.y = 0; bar.x[7] = 42;
>
and assuming sizeof(int) == 4, what is it that you think should
be defined by the C standard but is not? And the same question
for a struct if that is what you meant.
>
No, I mean struct and I mean 8.
And I mean that a typical implementation-defined behavior would be
bar.y==42 on LE machines and bar.y==42*2**24 on BE machines.
As it actually happens in reality with all production compilers.
Ah, you want to re-introduce Fortran's storage association and
common blocks, but without the type safety.
FORTAN allowed::
subroutine1:
COMMON /ALPHA/i,j,k,l,m,n
subroutine2:
COMMON /ALPHA/x.y.z
expecting {i,j} which are INT*4 to overlap with x Read*8 ;...
{Completely neglecting the BE/LE problems,...}
Les messages affichés proviennent d'usenet.