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
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
Clarifying description (since it currently isn't possible, which is the bug...)
I'm trying to figure out if the 3.4 milestone is appropriate. Is this a regression?
Yes, it's a regression on both the branch and mainline. GCC 2.95 accepts the code.
Confirmed a regression from 2.95.3.
It has been failing since at least 2000-12-31.
Not to be fixed for 3.3.3, it would take too much code rewriting.
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.
DR 295 applies during substitution, but not during deduction. Hence void bar(const volatile T& p) fails deduction for the call.
reopening ...
This is infact valid, but the std is far from clear that that is the case. See 3518 for details of the fix.