Bug 88774 - Qualification of parameters does not change a function type: Bug or standard defect?
Summary: Qualification of parameters does not change a function type: Bug or standard ...
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 9.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-01-09 19:15 UTC by Anders Granlund
Modified: 2019-01-10 17:09 UTC (History)
0 users

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 Anders Granlund 2019-01-09 19:15:45 UTC
Test case (prog.c):

  int main(void)
  {
    typedef void f(int);
    typedef void f(const int);
  }

Compilation command line:

  gcc prog.c -Wall -Wextra -std=c11 -pedantic-errors 

Observed behaviour:

  No error messages outputed.

Question:

  The function types in the two typedefs are compatible, but are they distinct?

  The standard is not very clear on this.

  If the two function types are distinct the expected behaviour is to get an 
  error message about redeclaring the typedef name  f  with a different type.

  Else the observed behaviour is expected and there is no bug.
Comment 1 jsm-csl@polyomino.org.uk 2019-01-09 21:01:19 UTC
Although the wording is different in the two cases (and the rule for 
return types is newer), I think qualifiers on function parameters should 
be considered as not part of the type just as with qualifiers on return 
types.  (Qualifiers on parameters *in the function definition* do affect 
uses of those parameters within the function definition.)  I think the 
introduction of the concept of types being the same simply failed to 
consider this issue.
Comment 2 Jonathan Wakely 2019-01-10 08:36:53 UTC
Yes, that's consistent with how C++ handles top-level cv-qualifiers in function parameters.
Comment 3 Anders Granlund 2019-01-10 17:09:34 UTC
Ok. Thanks for the answers.