Opened 5 years ago

Closed 3 months ago

#172 closed defect (fixed)

Anonymous struct can conflict across translation unit

Reported by: Thierry Delisle Owned by:
Priority: major Component: cfa-cc
Version: 1.0 Keywords: mangling, backwards-compatibility
Cc:

Description

Given a header fred.hfa with the following code:

typedef struct { /*...*/ } my_struct_t;

void foo( my_struct_t * );

This will create a struct of name anonymous[N] where [N] is replaced by a simple counter.

Now if fred.cfa and mary.cfa include the file as follows:

--- fred.cfa ---
#include "fred.hfa"

/* ... use foo() ... */

--- mary.cfa ---
typedef struct { int i; } my_int_t;
#include "fred.hfa"

/* ... use foo() ... */

In these 2 files, since the number of structs anonymous struct differs, foo will mangle differently.

This means that it may be impossible to link the 2 files together.

Note: linux makes heavy use of typedef struct which means this can break code easily

Change History (1)

comment:1 Changed 3 months ago by ajbeach

Resolution: fixed
Status: newclosed

Checked it. This seems to work.

Also, I believe it is covered by the test case anon (from linking/mangling/), so it is event tested, someone just forgot to close the issue.

Note: See TracTickets for help on using tickets.