Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C allows redefinition of a typedef #9

Open
kevinsneel opened this issue Apr 28, 2014 · 0 comments
Open

C allows redefinition of a typedef #9

kevinsneel opened this issue Apr 28, 2014 · 0 comments

Comments

@kevinsneel
Copy link

It is not actually true that 'a * b; ' is illegal if both are types. It is actually legal to define, e.g., a structure member as the same name as an existing typedef name. See, e.g., C99 6.7.7 example 3:

EXAMPLE 3 The following obscure constructions
typedef signed int t;
typedef int plain;
struct tag {
unsigned t:4;
const t:5;
plain r:5;
};
declare a typedef name t with type signed int,atypedef name plain with type int, and a structure with three bit-field members, one named t that contains values in the range [0, 15], ...

As far as I can see. nearly all redeclarations in a different namespace or inner scope are allowed. The only exception I see is in 6.9.1 paragraph 6: "An identifier declared as a typedef name shall not be redeclared as a parameter."

Unfortunately, it seems breaking that last rule is not uncommon. So maybe if we could allow that to be a warning, it would be very helpful.

Thanks for cast!
Kevin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant