On Thu, 6 Apr 2017, Bernd Edlinger wrote: > On 04/06/17 21:05, Florian Weimer wrote: > > On 04/06/2017 08:49 PM, Bernd Edlinger wrote: > > > >> For instance how do you "declare an object without a declared type"? > > > > malloc and other allocation functions return pointers to objects without > > a declared type. > > > > Thanks Florian, > > this discussion is very helpful. > > How about this for the documentation: > > @item typeless_storage > @cindex @code{typeless_storage} type attribute > In the context of section 6.5 paragraph 6 of the C11 standard, > an object of this type behaves as if it has no declared type. > In the context of section 6.5 paragraph 7 of the C11 standard, > an object or a pointer if this type behaves as if it were a > character type. > This is attribute is similar to the @code{may_alias} attribute, > except that it is not restricted to pointers. > > Example of use: > > @smallexample > typedef int __attribute__((__typeless_storage__)) int_a; > > int > main (void) > @{ > int_a a = 0x12345678; > short *b = (short *) &a; > > b[1] = 0; > > if (a == 0x12345678) > abort(); > > exit(0); > @} > @end smallexample
Seriously, do not suggest such broken case. There's a union to do this example portably. Richard.