c-semantics AT lists.cs.illinois.edu
Subject: C Semantics in K Framework
List archive
- From: Derek M Jones <derek AT knosof.co.uk>
- To: c-semantics AT cs.illinois.edu
- Subject: Re: [C-Semantics] unnamed struct members
- Date: Tue, 09 Aug 2011 21:01:21 +0100
- List-archive: <http://lists.cs.uiuc.edu/pipermail/c-semantics>
- List-id: C Semantics in K Framework <c-semantics.cs.illinois.edu>
- Organization: Knowledge Software, Ltd
John,
- the non-specific language in 6.2.5.20 (unchanged in TC3/N1256)
This is the sort of language you would expect in a brief overview.
- the fact that I can't find a compiler that rejects an unnamed,
non-bitfield struct member as a compile-time error (Clang, GCC, and
Intel CC all provide a warning, however)
Probably a hangover from the days when identifiers were optional on non-struct declarations (many compilers seem to have {incorrectly}
reused the same bits of syntax handling code in this area).
John
On 8/9/11 1:34 PM, Derek M Jones wrote:
John,_______________________________________________
I can't find any language in the C99 standard which forces unnamed
struct members to be bitfields.
The syntax of structure specifiers only supports optional
declarators for bit-fields.
Sentence 1390: http://c0x.coding-guidelines.com/6.7.2.1.html
Rather, we see text like this which
appears to refer to all member objects:
"A structure type describes a sequentially allocated nonempty set of
member objects (and, in certain circumstances, an incomplete array),
each of which has an optionally specified name and possibly distinct type."
Can you back up your interpretation?
Thanks,
John
On 8/9/11 1:06 PM, Derek M Jones wrote:
John,_______________________________________________
The C99 standard seems to make it clear that structs may contain unnamed
members. This argues that KCC and CompCert are correct.
Unnamed BIT-FIELD members.
Both Clang and GCC (even when given the --std=c99 flag) complain that
line 5 does not declare anything, and their output is consistent with
this claim.
This is correct.
Anyone know what's going on?
The code is making use of an extension to C.
Thanks,
John
int printf (const char *, ...);
struct S0
{
int;
int f1;
};
struct S3
{
int f2;
int f3;
};
union U4
{
struct S3 f0;
struct S0 f3;
};
union U4 g_110;
int main (void)
{
g_110.f3.f1 = 1;
printf ("%d\n", g_110.f0.f2);
return 0;
}
_______________________________________________
c-semantics mailing list
c-semantics AT cs.illinois.edu
http://lists.cs.uiuc.edu/mailman/listinfo/c-semantics
c-semantics mailing list
c-semantics AT cs.illinois.edu
http://lists.cs.uiuc.edu/mailman/listinfo/c-semantics
c-semantics mailing list
c-semantics AT cs.illinois.edu
http://lists.cs.uiuc.edu/mailman/listinfo/c-semantics
--
Derek M. Jones tel: +44 (0) 1252 520 667
Knowledge Software Ltd
mailto:derek AT knosof.co.uk
Source code analysis http://www.knosof.co.uk
- [C-Semantics] unnamed struct members, John Regehr, 08/09/2011
- Re: [C-Semantics] unnamed struct members, Derek M Jones, 08/09/2011
- Re: [C-Semantics] unnamed struct members, John Regehr, 08/09/2011
- Re: [C-Semantics] unnamed struct members, CUOQ Pascal, 08/09/2011
- Re: [C-Semantics] unnamed struct members, John Regehr, 08/09/2011
- Re: [C-Semantics] unnamed struct members, Derek M Jones, 08/09/2011
- Re: [C-Semantics] unnamed struct members, John Regehr, 08/09/2011
- Re: [C-Semantics] unnamed struct members, Derek M Jones, 08/09/2011
- Re: [C-Semantics] unnamed struct members, John Regehr, 08/09/2011
- Re: [C-Semantics] unnamed struct members, CUOQ Pascal, 08/09/2011
- Re: [C-Semantics] unnamed struct members, John Regehr, 08/09/2011
- Re: [C-Semantics] unnamed struct members, Derek M Jones, 08/09/2011
- Re: [C-Semantics] unnamed struct members, John Regehr, 08/09/2011
- Re: [C-Semantics] unnamed struct members, CUOQ Pascal, 08/09/2011
- Re: [C-Semantics] unnamed struct members, John Regehr, 08/09/2011
- Re: [C-Semantics] unnamed struct members, Derek M Jones, 08/09/2011
Archive powered by MHonArc 2.6.16.