Skip to Content.
Sympa Menu

c-semantics - Re: [C-Semantics] unnamed struct members

c-semantics AT lists.cs.illinois.edu

Subject: C Semantics in K Framework

List archive

Re: [C-Semantics] unnamed struct members


Chronological Thread 
  • 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 20:34:55 +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,

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


--
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




Archive powered by MHonArc 2.6.16.

Top of Page