Bug 32364 - Error from simple typedef/void combination
Summary: Error from simple typedef/void combination
Status: RESOLVED DUPLICATE of bug 9278
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-06-16 04:38 UTC by Daniel Richard G.
Modified: 2007-08-15 19:13 UTC (History)
10 users (show)

See Also:
Host: i386-unknown-freebsd4.8
Target: i386-unknown-freebsd4.8
Build: i386-unknown-freebsd4.8
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 Daniel Richard G. 2007-06-16 04:38:46 UTC
Came across this head-scratcher in building Qt with GCC 4.2.0. Heavily simplified version:

foo.cxx:
    typedef void (*funcptr)(void);

    typedef void GLvoid;
    typedef GLvoid (*_GLUfuncptr)(GLvoid);

    int foo(void) { return 1; }

$ g++ -c foo.cxx
foo.cxx:4: error: '<anonymous>' has incomplete type
foo.cxx:4: error: invalid use of 'GLvoid'

Compiles fine with 4.1.2 and 2.95.4.
Comment 1 Andrew Pinski 2007-06-16 04:53:08 UTC
This is actually invalid C++ which we did not reject before 4.2.0.

*** This bug has been marked as a duplicate of 9278 ***
Comment 2 Craig Powers 2007-08-15 19:08:00 UTC
(In reply to comment #0)
> Came across this head-scratcher in building Qt with GCC 4.2.0. Heavily
> simplified version:
> 
> foo.cxx:
>     typedef void (*funcptr)(void);
> 
>     typedef void GLvoid;
>     typedef GLvoid (*_GLUfuncptr)(GLvoid);
> 
>     int foo(void) { return 1; }
> 
> $ g++ -c foo.cxx
> foo.cxx:4: error: '<anonymous>' has incomplete type
> foo.cxx:4: error: invalid use of 'GLvoid'
> 
> Compiles fine with 4.1.2 and 2.95.4.
> 

You can patch GL/glu.h as e.g.
#ifdef __cplusplus
typedef void (*_GLUfuncptr)(void);
#else
typedef GLvoid (*_GLUfuncptr)(GLvoid);
#endif

I'm assuming that the line that now fails to compile in C++ is still valid C.  I'll admit, I don't really see the point to using a typedef for void.
Comment 3 Craig Powers 2007-08-15 19:13:13 UTC
Looking at CVS for glu.h, the official patch is:
#ifdef __cplusplus
typedef GLvoid (*_GLUfuncptr)();
#else

...