Bug 10807 - [DR 295] It should be possible to cv-qualify function types, if the CV qualifications are introduced through a typedef or a template argument
Summary: [DR 295] It should be possible to cv-qualify function types, if the CV qualif...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.0
: P3 critical
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks: 3518 6628
  Show dependency treegraph
 
Reported: 2003-05-15 18:16 UTC by Giovanni Bajo
Modified: 2004-04-05 15:55 UTC (History)
2 users (show)

See Also:
Host: i686-pc-cygwin
Target: i686-pc-cygwin
Build:
Known to work: 2.95.3
Known to fail:
Last reconfirmed: 2004-03-26 06:36:27


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Giovanni Bajo 2003-05-15 18:16:00 UTC
The following code is legal as per approval of DR 295:

-------------------------------------------------
// CV qualifications through typedefs are ok (and ignored)
typedef void func_type(int);
typedef const volatile func_type cv_func_type;

void func(int) {}
cv_func_type* func_ptr = func;


// CV qualifications through template arguments are ok (and ignored)
template <typename T>
void bar(const volatile T& p)
{
    typedef const volatile T cvT;
    cvT* func = p;

    func(10);
}

int main()
{
    bar(func);
}
-------------------------------------------------
dr295.cpp:3: error: `const volatile' qualifiers cannot be applied to `void ()(int)'
dr295.cpp: In function `int main()':
dr295.cpp:21: error: no matching function for call to `bar(void (&)(int))'


Please, notice that c++/3518 is surely related to this PR.
So, once this is implemented, c++/3518 should be checked
again.

Release:
3.4

Environment:
i686-pc-cygwin

How-To-Repeat:
Compile the above snippet
Comment 1 Dara Hazeghi 2003-05-31 19:58:09 UTC
Confirmed with gcc 3.3 branch and mainline (20030525). gcc 3.2 issues:
dr295.cpp:3: warning: ignoring `volatile' qualifiers on `void ()(int)'
dr295.cpp: In instantiation of `void bar(const volatile T&) [with T = void ()(int)]':
dr295.cpp:21:   instantiated from here
dr295.cpp:12: warning: ignoring `volatile' qualifiers on `void ()(int)'
dr295.cpp: In function `void bar(const volatile T&) [with T = void ()(int)]':
dr295.cpp:13: warning: ignoring `volatile' qualifiers on `void ()(int)'
dr295.cpp:14: warning: ignoring `volatile' qualifiers on `void ()(int)'

Thanks to the bugzilla switchover, this somehow got marked unconfirmed, so I'm changing that...

Dara
Comment 2 Nathanael C. Nerode 2003-08-03 18:14:00 UTC
Clarifying description (since it currently isn't possible, which is the bug...)
Comment 3 Mark Mitchell 2003-12-17 05:36:54 UTC
I'm trying to figure out if the 3.4 milestone is appropriate.

Is this a regression?
Comment 4 Giovanni Bajo 2003-12-18 03:20:07 UTC
Yes, it's a regression on both the branch and mainline. GCC 2.95 accepts the 
code.
Comment 5 Andrew Pinski 2003-12-22 03:33:43 UTC
Confirmed a regression from 2.95.3.
Comment 6 Andrew Pinski 2003-12-26 18:26:34 UTC
It has been failing since at least 2000-12-31.
Comment 7 Andrew Pinski 2004-01-11 01:41:55 UTC
Not to be fixed for 3.3.3, it would take too much code rewriting.
Comment 8 Mark Mitchell 2004-02-05 02:37:23 UTC
I don't think it's appropriate to qualify this as a regression since (a) the
standard as it presently exists does not allow the code, and (b) making this
change will break existing code.

We should implement DR 295 at some point, but it's certainly not release critical.

I've removed the target milestone and the regression markers.
Comment 9 Nathan Sidwell 2004-04-02 15:03:08 UTC
DR 295 applies during substitution, but not during deduction. Hence
  void bar(const volatile T& p)
fails deduction for the call.
Comment 10 Nathan Sidwell 2004-04-05 15:53:59 UTC
reopening ...
Comment 11 Nathan Sidwell 2004-04-05 15:55:00 UTC
This is infact valid, but the std is far from clear that that is the case.
See 3518 for details of the fix.