Bug 57466 (cwg1584) - [DR 1584] Argument deduction fails for 'const T*' when T is function type
Summary: [DR 1584] Argument deduction fails for 'const T*' when T is function type
Status: SUSPENDED
Alias: cwg1584
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.7.3
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks: c++-core-issues 57465
  Show dependency treegraph
 
Reported: 2013-05-30 10:07 UTC by Jonathan Wakely
Modified: 2022-01-09 00:46 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2013-05-30 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Wakely 2013-05-30 10:07:43 UTC
(This is the root cause of PR 57465, but I have a workaround for the library.)


template<typename T>
  constexpr bool
  is_pointer(const T*)
  { return true; }

template<typename T>
  constexpr bool
  is_pointer(const T&)
  { return false; }

using F = void();

constexpr F* f = nullptr;

static_assert( is_pointer(f), "function pointer is a pointer" );

G++ fails the static assertion:

t.cc:15:1: error: static assertion failed: function pointer is a pointer
 static_assert( is_pointer(f), "function pointer is a pointer" );
 ^

The first function template should be instantiated as bool is_pointer(F*) but instead deduction fails because:
   types 'const T' and 'F {aka void()}' have incompatible cv-qualifiers


Note deduction succeeds with an explicit template argument:

template<typename T>
  constexpr bool
  is_pointer(const T*)
  { return true; }

using F = void();

constexpr F* f = nullptr;

constexpr bool pass = is_pointer<F>(f);
constexpr bool fail = is_pointer(f);
Comment 1 Daniel Krügler 2013-05-30 11:03:35 UTC
I think this observation was the reason why I filed:

http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1584

Notice that albeit the current CWG issue status contains a P/R, there is indication for being some contradiction to the assertions made in

www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#503

(I have posted this to the CWG committee recently)
Comment 2 Jonathan Wakely 2013-05-30 11:23:04 UTC
Ah yes, thanks!
Comment 3 Paolo Carlini 2014-07-08 10:21:00 UTC
DR1584 is Ready.
Comment 4 paolo@gcc.gnu.org 2014-07-09 21:23:39 UTC
Author: paolo
Date: Wed Jul  9 21:23:06 2014
New Revision: 212410

URL: https://gcc.gnu.org/viewcvs?rev=212410&root=gcc&view=rev
Log:
/cp
2014-07-09  Paolo Carlini  <paolo.carlini@oracle.com>

	DR 1584
	PR c++/57466
	* pt.c (check_cv_quals_for_unify): Implement resolution, disregard
	cv-qualifiers of function types.

/testsuite
2014-07-09  Paolo Carlini  <paolo.carlini@oracle.com>

	DR 1584
	PR c++/57466
	* g++.dg/template/pr57466.C: New.
	* g++.dg/cpp0x/pr57466.C: Likewise.
	* g++.dg/template/unify6.C: Update.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/pr57466.C
    trunk/gcc/testsuite/g++.dg/template/pr57466.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/pt.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/template/unify6.C
Comment 5 Paolo Carlini 2014-07-09 21:24:41 UTC
Fixed for 4.10.
Comment 6 paolo@gcc.gnu.org 2014-08-15 16:24:21 UTC
Author: paolo
Date: Fri Aug 15 16:23:47 2014
New Revision: 214027

URL: https://gcc.gnu.org/viewcvs?rev=214027&root=gcc&view=rev
Log:
/cp
2014-08-15  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/62072
	Revert:
	2014-07-09  Paolo Carlini  <paolo.carlini@oracle.com>

	DR 1584
	PR c++/57466
	* pt.c (check_cv_quals_for_unify): Implement resolution, disregard
	cv-qualifiers of function types.

/testsuite
2014-08-15  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/62072
	Revert:
	2014-07-09  Paolo Carlini  <paolo.carlini@oracle.com>

	DR 1584
	PR c++/57466
	* g++.dg/template/pr57466.C: New.
	* g++.dg/cpp0x/pr57466.C: Likewise.
	* g++.dg/template/unify6.C: Update.

	* g++.dg/cpp0x/sfinae52.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/sfinae52.C
Removed:
    trunk/gcc/testsuite/g++.dg/cpp0x/pr57466.C
    trunk/gcc/testsuite/g++.dg/template/pr57466.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/pt.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/template/unify6.C
Comment 7 Paolo Carlini 2014-08-15 16:26:43 UTC
Patch reverted, unfortunately.
Comment 8 Paolo Carlini 2014-08-16 07:58:56 UTC
Still working on this.
Comment 9 Jakub Jelinek 2015-04-22 11:58:24 UTC
GCC 5.1 has been released.
Comment 10 Richard Biener 2015-07-16 09:12:59 UTC
GCC 5.2 is being released, adjusting target milestone to 5.3.
Comment 11 Richard Biener 2015-12-04 10:46:24 UTC
GCC 5.3 is being released, adjusting target milestone.
Comment 12 Paolo Carlini 2016-06-01 09:07:18 UTC
I'm having another look at this, and the last comments added to DR1584 and coming to the conclusion that gcc probably doesn't need further work, in particular the patch that I had to revert pointed to a real issue. Other comments?
Comment 13 Richard Biener 2016-06-03 10:06:08 UTC
GCC 5.4 is being released, adjusting target milestone.
Comment 14 Jonathan Wakely 2016-06-04 08:47:37 UTC
I agree that G++ seems to be correct according to the revised direction.
Comment 15 Paolo Carlini 2016-09-22 16:23:45 UTC
Great. I'm going to double check with Jason before resolving the bug.
Comment 16 Paolo Carlini 2017-05-17 20:03:00 UTC
Shall we definitely close this, then?
Comment 17 Jonathan Wakely 2017-05-17 20:28:39 UTC
Fine by me.

EDG agrees with GCC, but Clang accepts the original example. I guess they'll change when 1584 gets resolved.
Comment 18 Paolo Carlini 2017-05-18 09:24:06 UTC
Thanks Jon. It occurs to me that bugs depending on DRs not yet resolved normally are suspended. Let's do that here too.
Comment 19 Andrew Pinski 2021-08-05 03:14:25 UTC
(In reply to Jonathan Wakely from comment #17)
> Fine by me.
> 
> EDG agrees with GCC, but Clang accepts the original example. I guess they'll
> change when 1584 gets resolved.

clang started to reject in clang 7.0.0.

Is there anything else that needs to be done?
Comment 20 Jonathan Wakely 2021-08-05 15:33:41 UTC
The core issue is still open, for some reason.