Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #74369

Re: How does strict aliasing work with parallel arrays in a union or const-initialized data

Path csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail
From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: How does strict aliasing work with parallel arrays in a union or const-initialized data
Date Fri, 30 Oct 2015 14:16:42 -0700
Organization None to speak of
Lines 45
Message-ID <ln1tcc9hvp.fsf@kst-u.example.com> (permalink)
References <44332515-f0c2-40f4-b435-c1351188e3bc@googlegroups.com> <kfn4mhfefyv.fsf@x-alumni2.alumni.caltech.edu> <6408f9ec-e8d2-4526-96ca-271e1d201484@googlegroups.com> <kfn611qdcu2.fsf@x-alumni2.alumni.caltech.edu> <b49266e4-9532-4179-9d4c-fd2c02d7236b@googlegroups.com> <lnlhambmrj.fsf@kst-u.example.com> <kfnoafibkpk.fsf@x-alumni2.alumni.caltech.edu> <lnh9labhuv.fsf@kst-u.example.com> <n10loj$56p$1@dont-email.me>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 8bit
Injection-Info mx02.eternal-september.org; posting-host="945944de09706c9b4e29b53c9d2efdc2"; logging-data="6351"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+U2yU9+/zfH7S2NKkgxpO2"
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)
Cancel-Lock sha1:ZtBmFiPOL3Mcx7sr0lPHP4SL578= sha1:DDa0+3cZ1t/DrNGzHD1rWDt+mCk=
Xref csiph.com comp.lang.c:74369

Show key headers only | View raw


Eric Sosman <esosman@comcast-dot-net.invalid> writes:
> On 10/28/2015 9:09 PM, Keith Thompson wrote:
>> Tim Rentsch <txr@alumni.caltech.edu> writes:
>>> Keith Thompson <kst-u@mib.org> writes:
>>>
>>>> supercat@casperkitty.com writes:
>>>>> On Wednesday, October 28, 2015 at 2:15:29 PM UTC-5, Tim Rentsch wrote:
>>>>>> supercat writes:
>>>>>>> [snip]
>>>>>
>>>>> If I have one translation unit which contains the definitions:
>>>>>
>>>>>     struct FOO { int x,y; char b[]; };
>>>>>     struct GOO { int x,y; char b[4]; };
>>>>>  [...]
>>
>> Right.  I was thinking of the more general case of two distinct struct
>> types with a common initial subsequence.  I missed the fact that struct
>> FOO and struct GOO are compatible.
>
> 	$ cat foo.c
> 	struct FOO { int x,y; char b[]; };
> 	struct GOO { int x,y; char b[4]; };
> 	int main(void) {
> 	   struct FOO f;
> 	   struct GOO g;
> 	   f = g;
> 	   return 0;
> 	}
> 	$ gcc -std=c99 foo.c
> 	foo.c: In function ‘main’:
> 	foo.c:6:6: error: incompatible types when assigning to type ‘struct 
> FOO’ from type ‘struct GOO’
> 	    f = g;
> 	      ^
>
> (Stupid gcc!)

Smart gcc, actually.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

How does strict aliasing work with parallel arrays in a union or const-initialized data supercat@casperkitty.com - 2015-10-21 16:47 -0700
  Re: How does strict aliasing work with parallel arrays in a union or const-initialized data Tim Rentsch <txr@alumni.caltech.edu> - 2015-10-24 21:20 -0700
    Re: How does strict aliasing work with parallel arrays in a union or const-initialized data supercat@casperkitty.com - 2015-10-25 11:44 -0700
      Re: How does strict aliasing work with parallel arrays in a union or const-initialized data Tim Rentsch <txr@alumni.caltech.edu> - 2015-10-28 12:15 -0700
        Re: How does strict aliasing work with parallel arrays in a union or const-initialized data supercat@casperkitty.com - 2015-10-28 14:25 -0700
          Re: How does strict aliasing work with parallel arrays in a union or const-initialized data Keith Thompson <kst-u@mib.org> - 2015-10-28 16:23 -0700
            Re: How does strict aliasing work with parallel arrays in a union or const-initialized data Tim Rentsch <txr@alumni.caltech.edu> - 2015-10-28 17:08 -0700
              Re: How does strict aliasing work with parallel arrays in a union or const-initialized data Keith Thompson <kst-u@mib.org> - 2015-10-28 18:09 -0700
                Re: How does strict aliasing work with parallel arrays in a union or const-initialized data supercat@casperkitty.com - 2015-10-28 20:02 -0700
                Re: How does strict aliasing work with parallel arrays in a union or const-initialized data Bartc <bc@freeuk.com> - 2015-10-29 10:55 +0000
                Re: How does strict aliasing work with parallel arrays in a union or const-initialized data supercat@casperkitty.com - 2015-10-29 06:50 -0700
                Re: How does strict aliasing work with parallel arrays in a union or const-initialized data Keith Thompson <kst-u@mib.org> - 2015-10-29 08:52 -0700
                Re: How does strict aliasing work with parallel arrays in a union or const-initialized data supercat@casperkitty.com - 2015-10-31 10:21 -0700
                Re: How does strict aliasing work with parallel arrays in a union or const-initialized data Keith Thompson <kst-u@mib.org> - 2015-10-29 08:50 -0700
                Re: How does strict aliasing work with parallel arrays in a union or const-initialized data supercat@casperkitty.com - 2015-10-29 12:25 -0700
                Re: How does strict aliasing work with parallel arrays in a union or const-initialized data Tim Rentsch <txr@alumni.caltech.edu> - 2015-10-30 13:02 -0700
                Re: How does strict aliasing work with parallel arrays in a union or const-initialized data Keith Thompson <kst-u@mib.org> - 2015-10-30 13:35 -0700
                Re: How does strict aliasing work with parallel arrays in a union or const-initialized data Tim Rentsch <txr@alumni.caltech.edu> - 2015-10-30 19:57 -0700
                Re: How does strict aliasing work with parallel arrays in a union or const-initialized data Keith Thompson <kst-u@mib.org> - 2015-10-31 12:27 -0700
                Re: How does strict aliasing work with parallel arrays in a union or const-initialized data Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-10-30 17:02 -0400
                Re: How does strict aliasing work with parallel arrays in a union or const-initialized data Keith Thompson <kst-u@mib.org> - 2015-10-30 14:16 -0700
                Re: How does strict aliasing work with parallel arrays in a union or const-initialized data supercat@casperkitty.com - 2015-10-31 08:13 -0700
                Re: How does strict aliasing work with parallel arrays in a union or const-initialized data Tim Rentsch <txr@alumni.caltech.edu> - 2015-10-31 08:42 -0700
                Re: How does strict aliasing work with parallel arrays in a union or const-initialized data supercat@casperkitty.com - 2015-10-31 10:40 -0700
                Re: How does strict aliasing work with parallel arrays in a union or const-initialized data Tim Rentsch <txr@alumni.caltech.edu> - 2015-11-02 01:45 -0800
                Re: How does strict aliasing work with parallel arrays in a union or const-initialized data supercat@casperkitty.com - 2015-11-02 06:57 -0800
                Re: How does strict aliasing work with parallel arrays in a union or const-initialized data Tim Rentsch <txr@alumni.caltech.edu> - 2015-11-02 08:12 -0800
                Re: How does strict aliasing work with parallel arrays in a union or const-initialized data supercat@casperkitty.com - 2015-11-02 08:54 -0800
                Re: How does strict aliasing work with parallel arrays in a union or const-initialized data Tim Rentsch <txr@alumni.caltech.edu> - 2015-11-04 07:24 -0800
                Re: How does strict aliasing work with parallel arrays in a union or const-initialized data supercat@casperkitty.com - 2015-11-04 09:22 -0800
                Re: How does strict aliasing work with parallel arrays in a union or const-initialized data Tim Rentsch <txr@alumni.caltech.edu> - 2015-11-04 19:48 -0800
                Re: How does strict aliasing work with parallel arrays in a union or const-initialized data supercat@casperkitty.com - 2015-11-05 09:44 -0800
                Re: How does strict aliasing work with parallel arrays in a union or const-initialized data Tim Rentsch <txr@alumni.caltech.edu> - 2015-11-07 10:17 -0800
                Re: How does strict aliasing work with parallel arrays in a union or const-initialized data raltbos@xs4all.nl (Richard Bos) - 2015-11-10 15:37 +0000
                Re: How does strict aliasing work with parallel arrays in a union or const-initialized data supercat@casperkitty.com - 2015-11-10 09:01 -0800
          Re: How does strict aliasing work with parallel arrays in a union or const-initialized data Tim Rentsch <txr@alumni.caltech.edu> - 2015-10-28 16:48 -0700
        Re: How does strict aliasing work with parallel arrays in a union or const-initialized data Keith Thompson <kst-u@mib.org> - 2015-10-28 16:11 -0700
          Re: How does strict aliasing work with parallel arrays in a union or const-initialized data Tim Rentsch <txr@alumni.caltech.edu> - 2015-10-28 16:37 -0700

csiph-web