Bug 19514 - bogus warning about complex "integer" types from typedef
Summary: bogus warning about complex "integer" types from typedef
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: pending (show other bugs)
Version: 3.4.3
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-01-18 22:02 UTC by stevenj@ab-initio.mit.edu
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description stevenj@ab-initio.mit.edu 2005-01-18 22:02:48 UTC
NOTE: Defaulting component because reported component no longer exists

When compiling the following two lines:

typedef double R;
typedef R _Complex C;

with the flags -std=c99 -pedantic, gcc gives the bogus warning:

foo.c:2: warning: ISO C does not support complex integer types

(Code based on the above definitions seems to work, however.)

Environment:
System: Linux ab-initio 2.4.25 #1 SMP Fri Jul 9 17:11:47 EDT 2004 i686 unknown
Architecture: i686

	
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../configure --prefix=/usr/local/gcc-3.4 --enable-languages=c,c++,f77

How-To-Repeat:
Create a file foo.c with the above two lines, and compile with
	gcc -std=c99 -pedantic -c foo.c
Comment 1 stevenj@ab-initio.mit.edu 2005-01-18 22:02:48 UTC
Fix:
Simply ignoring the warning seems to work okay.
Comment 2 jsm-csl@polyomino.org.uk 2005-01-18 22:20:12 UTC
Subject: Re:  New: bogus warning about complex "integer"
 types from typedef

On Tue, 18 Jan 2005, gcc-bugzilla at gcc dot gnu dot org wrote:

> When compiling the following two lines:
> 
> typedef double R;
> typedef R _Complex C;

This is not valid code; you can't use _Complex together with a typedef, 
only together with "float", "double" or "long double" in one of the forms 
listed in C99.

The misleading diagnostic is a bug, which has been fixed in mainline: you 
now get the error

t.c:2: error: two or more data types in declaration specifiers

Comment 3 Andrew Pinski 2005-01-18 22:52:53 UTC
Invalid based on JSM's comment.
Comment 4 stevenj@fftw.org 2005-01-18 22:56:55 UTC
Subject: Re:  bogus warning about complex "integer" types
 from typedef

On Tue, 18 Jan 2005, joseph at codesourcery dot com wrote:
>> typedef double R;
>> typedef R _Complex C;
>
> This is not valid code; you can't use _Complex together with a typedef,
> only together with "float", "double" or "long double" in one of the forms
> listed in C99.

My copy of the C99 draft standard states (sec. 6.7.7):

 	"A typedef declaration does not introduce a new type, only a
 	 synonym for the type so specified."

According to this, "R complex" should be a synonym for "double complex", 
and therefore should be valid code.  What justification do you have for 
claiming otherwise?
Comment 5 stevenj@fftw.org 2005-01-18 23:15:10 UTC
Subject: Re:  bogus warning about complex "integer" types
 from typedef

Okay, I guess I see what you mean.  "double" in "double _Complex" is 
arguably not a "type", but rather a type-specifier as defined in 6.7.2, 
and the "each list of type-specifiers shall be one of the following sets",
a prescribed list of combinations that does not include typedefs.

What an annoyance; one has to define R via the preprocessor, then, in 
order to use consistent floating-point precisions everywhere in a program.
Comment 6 jsm-csl@polyomino.org.uk 2005-01-18 23:52:59 UTC
Subject: Re:  bogus warning about complex "integer" types
 from typedef

On Tue, 18 Jan 2005, stevenj at fftw dot org wrote:

> Okay, I guess I see what you mean.  "double" in "double _Complex" is 
> arguably not a "type", but rather a type-specifier as defined in 6.7.2, 
> and the "each list of type-specifiers shall be one of the following sets",
> a prescribed list of combinations that does not include typedefs.

Yes, that's my point.  "double _Complex" is one valid list of type 
specifiers.  "typedef name" is another, listed separately - a single type 
specifier, not part of any valid combinations.