public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [v3 patch] Fix friend declaration so it is visible to name lookup
@ 2015-08-20 20:36 Jonathan Wakely
  2015-08-20 22:32 ` Paolo Carlini
  0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Wakely @ 2015-08-20 20:36 UTC (permalink / raw)
  To: libstdc++, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 146 bytes --]

Jason pointed out this isn't valid, and is going to fail to compile
soon with a fix he's making.

Tested powerpc64le-linux, committed to trunk.



[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 1970 bytes --]

commit 89c676b9c2008823e7bbb7d5db615d908b1ea27d
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu Aug 20 20:51:39 2015 +0100

    	* include/experimental/any (__any_caster): Define at namespace scope
    	so the name is visible to name lookup.
    	* testsuite/experimental/any/misc/any_cast_neg.cc: Adjust dg-error.

diff --git a/libstdc++-v3/include/experimental/any b/libstdc++-v3/include/experimental/any
index dae82b5..4cdc1dc 100644
--- a/libstdc++-v3/include/experimental/any
+++ b/libstdc++-v3/include/experimental/any
@@ -296,14 +296,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     _Storage _M_storage;
 
     template<typename _Tp>
-      friend void* __any_caster(const any* __any)
-      {
-	if (__any->_M_manager != &_Manager<decay_t<_Tp>>::_S_manage)
-	  return nullptr;
-	_Arg __arg;
-	__any->_M_manager(_Op_access, __any, &__arg);
-	return __arg._M_obj;
-      }
+      friend void* __any_caster(const any* __any);
 
     // Manage in-place contained object.
     template<typename _Tp>
@@ -396,6 +389,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     }
   // @}
 
+  template<typename _Tp>
+    void* __any_caster(const any* __any)
+    {
+      if (__any->_M_manager != &any::_Manager<decay_t<_Tp>>::_S_manage)
+	return nullptr;
+      any::_Arg __arg;
+      __any->_M_manager(any::_Op_access, __any, &__arg);
+      return __arg._M_obj;
+    }
+
   /**
    * @brief Access the contained object.
    *
diff --git a/libstdc++-v3/testsuite/experimental/any/misc/any_cast_neg.cc b/libstdc++-v3/testsuite/experimental/any/misc/any_cast_neg.cc
index 1d1180c..5c7595d 100644
--- a/libstdc++-v3/testsuite/experimental/any/misc/any_cast_neg.cc
+++ b/libstdc++-v3/testsuite/experimental/any/misc/any_cast_neg.cc
@@ -26,5 +26,5 @@ void test01()
   using std::experimental::any_cast;
 
   const any y(1);
-  any_cast<int&>(y); // { dg-error "qualifiers" "" { target { *-*-* } } 360 }
+  any_cast<int&>(y); // { dg-error "qualifiers" "" { target { *-*-* } } 353 }
 }

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [v3 patch] Fix friend declaration so it is visible to name lookup
  2015-08-20 20:36 [v3 patch] Fix friend declaration so it is visible to name lookup Jonathan Wakely
@ 2015-08-20 22:32 ` Paolo Carlini
  2015-08-21 13:33   ` Jonathan Wakely
  0 siblings, 1 reply; 4+ messages in thread
From: Paolo Carlini @ 2015-08-20 22:32 UTC (permalink / raw)
  To: Jonathan Wakely, libstdc++, gcc-patches

Hi,

On 08/20/2015 10:21 PM, Jonathan Wakely wrote:
> Jason pointed out this isn't valid, and is going to fail to compile
> soon with a fix he's making.
I seem to remember that at some point we had the exact same issue with 
some member operator<< and operator>> of <random>.

Paolo.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [v3 patch] Fix friend declaration so it is visible to name lookup
  2015-08-20 22:32 ` Paolo Carlini
@ 2015-08-21 13:33   ` Jonathan Wakely
  2015-08-21 13:40     ` Paolo Carlini
  0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Wakely @ 2015-08-21 13:33 UTC (permalink / raw)
  To: Paolo Carlini; +Cc: libstdc++, gcc-patches

On 21/08/15 00:03 +0200, Paolo Carlini wrote:
>Hi,
>
>On 08/20/2015 10:21 PM, Jonathan Wakely wrote:
>>Jason pointed out this isn't valid, and is going to fail to compile
>>soon with a fix he's making.
>I seem to remember that at some point we had the exact same issue with 
>some member operator<< and operator>> of <random>.

I don't remember that, but hopefully we won't have any more problems
like this now that Jason is making the front-end diagnose it.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [v3 patch] Fix friend declaration so it is visible to name lookup
  2015-08-21 13:33   ` Jonathan Wakely
@ 2015-08-21 13:40     ` Paolo Carlini
  0 siblings, 0 replies; 4+ messages in thread
From: Paolo Carlini @ 2015-08-21 13:40 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: libstdc++, gcc-patches

Hi,

On 08/21/2015 02:57 PM, Jonathan Wakely wrote:
> On 21/08/15 00:03 +0200, Paolo Carlini wrote:
>> Hi,
>>
>> On 08/20/2015 10:21 PM, Jonathan Wakely wrote:
>>> Jason pointed out this isn't valid, and is going to fail to compile
>>> soon with a fix he's making.
>> I seem to remember that at some point we had the exact same issue 
>> with some member operator<< and operator>> of <random>.
>
> I don't remember that, but hopefully we won't have any more problems
> like this now that Jason is making the front-end diagnose it.
Yes. For your curiosity, I think I had in mind libstdc++/54376, which, 
besides being about operator==, wasn't the same issue because involved 
*template* classes. In any case, the lesson is that inline template 
friends are consistently rather evil ;)

Paolo.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-08-21 13:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-20 20:36 [v3 patch] Fix friend declaration so it is visible to name lookup Jonathan Wakely
2015-08-20 22:32 ` Paolo Carlini
2015-08-21 13:33   ` Jonathan Wakely
2015-08-21 13:40     ` Paolo Carlini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).