The C++ standard says this about the void parameter list:

"The parameter list (void) is equivalent to the empty parameter list."
(8.3.5 [dcl.fct] paragraph 2)

The C99 standard apparently says something slightly different, though I'm
afraid I'm quoting from a draft here:

"The special case of an unnamed parameter of type void as the only item in the
list specifies that the function has no parameters."
(6.7.5.3 paragraph 10)

If I understand these correctly, this means a C compiler must take type aliases
into account before checking for the special case whereas a C++ compiler must
not.

The development version of g++ follows the C++ standard in this respect,
whereas older versions of g++ follow the C standard.  During testing of the new
version in Debian, we found that this change broke a C++ program that uses the
OpenAL library, one of whose headers used a type alias for void in a function
parameter list; see http://bugs.debian.org/361707

Given that this special case only exists in C++ for compatibility with C, it
seems to be a defect in the standard that it is defined slightly differently,
and accordingly I have submitted a defect report. I think g++ should not be
changed to follow the C++ standard in this respect until this has been resolved
by the C++ standard committee.


-- 
           Summary: Special case for void parameter list differs from C
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ben at decadentplace dot org dot uk


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27252

Reply via email to