User account creation filtered due to spam.

Bug 27252 - Special case for void parameter list differs from C
Summary: Special case for void parameter list differs from C
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: 2006-04-22 00:13 UTC by Ben Hutchings
Modified: 2006-04-22 00:28 UTC (History)
7 users (show)

See Also:
Host:
Target:
Build:
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 Ben Hutchings 2006-04-22 00:13:14 UTC
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.
Comment 1 Andrew Pinski 2006-04-22 00:17:17 UTC
This was an undocumented extension.  Hint the word is really a bug and not an extension.

Maybe something should go to changes.html but that is not really an issue.

*** This bug has been marked as a duplicate of 9278 ***
Comment 2 Andrew Pinski 2006-04-22 00:21:22 UTC
http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/cwg_closed.html#18
was the Defect report for the C++ standard already.
Comment 3 Andrew Pinski 2006-04-22 00:28:04 UTC
One more thing is that filing a bug report is not the correct approach to filing a defect report with the standard since there was already a defect which was closed as NAD (not a defect).