Bug 56693 - [DR 1584] Fail to ignore const qualification on top of a function type.
Summary: [DR 1584] Fail to ignore const qualification on top of a function type.
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.8.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Reported: 2013-03-22 23:30 UTC by Cassio Neri
Modified: 2021-08-13 17:25 UTC (History)
2 users (show)

See Also:
Known to work:
Known to fail:
Last reconfirmed: 2013-03-23 00:00:00


Note You need to log in before you can comment on or make changes to this bug.
Description Cassio Neri 2013-03-22 23:30:13 UTC
The following code:

void f() {}

template <typename T> void g(const T*) { }

int main() {

raises an error with this note:

    types 'const T' and 'void()' have incompatible cv-qualifiers

Attempting to instantiate g creates a function that takes a pointer to a const T where T = void(). Since there's no such thing as a "const function", this explains the note. However, C++11 8.3.5/6 says

"The effect of a cv-qualifier-seq in a function declarator is not the same as adding cv-qualification on top of the function type. In the latter case, the cv-qualifiers are ignored."

Hence, the const qualifier should be ignored and the code should compile. (It does compile with clang and visual studio.)

For more information see:
Comment 1 Daniel Krügler 2013-03-23 12:20:30 UTC
This looks like


to me
Comment 2 Andrew Pinski 2021-08-12 04:06:40 UTC
Notes from the May, 2015 meeting:

The consensus of CWG was that the cv-qualification of the argument and parameter must match, so the original example should be rejected.