public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/39413]  New: static_assert and SFINAE
@ 2009-03-09 17:20 piotr dot wyderski at gmail dot com
  2009-03-09 17:48 ` [Bug c++/39413] " paolo dot carlini at oracle dot com
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: piotr dot wyderski at gmail dot com @ 2009-03-09 17:20 UTC (permalink / raw)
  To: gcc-bugs

G++ fails when compiling the following program in
g++0x mode. It displays "spooky action at a distance"
when instantiating the member_ptr template, but I
expect the converting assignment operator from weak_ptr
to be selected instead.

-------------------------8<-----------------------


#include <type_traits>

    class A {

    };

    class B : public A {

    };

    class C {

    };


    namespace gc {

        template <typename T> class member_ptr;
    }


    template <typename T> class weak_ptr {

    public:

        weak_ptr() {}

        template <typename X> weak_ptr(const weak_ptr<X>& v) {}

        weak_ptr(const weak_ptr&) = default;

        weak_ptr(const gc::member_ptr<T>& v);

        ~weak_ptr() = default;

        // ------------------

        weak_ptr& operator =(const weak_ptr&) = default;

        template <typename X> weak_ptr& operator =(const weak_ptr<X>& v) {
return *this; }
    };

    namespace gc {

        template <typename T> class member_ptr {

            static_assert(std::is_base_of<C, T>::value,
              "spooky action at a distance");
        };
    }



int main(int argc, char *argv[]) {

    weak_ptr<A> ap1;
    weak_ptr<B> bp1;

    ap1 = bp1;

    return 0;
}


-------------------------8<-----------------------


-- 
           Summary: static_assert and SFINAE
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: piotr dot wyderski at gmail dot com
  GCC host triplet: GCC-4.4.0 (20090309), Cygwin, Windows XP


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39413


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

* [Bug c++/39413] static_assert and SFINAE
  2009-03-09 17:20 [Bug c++/39413] New: static_assert and SFINAE piotr dot wyderski at gmail dot com
@ 2009-03-09 17:48 ` paolo dot carlini at oracle dot com
  2009-03-09 18:10 ` paolo dot carlini at oracle dot com
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: paolo dot carlini at oracle dot com @ 2009-03-09 17:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from paolo dot carlini at oracle dot com  2009-03-09 17:48 -------
let's try to simplify the issue as much as possible... are defaulted / deleted
functions really necessary to trigger the bug? Thus, is c++0x mode really
necessary?


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39413


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

* [Bug c++/39413] static_assert and SFINAE
  2009-03-09 17:20 [Bug c++/39413] New: static_assert and SFINAE piotr dot wyderski at gmail dot com
  2009-03-09 17:48 ` [Bug c++/39413] " paolo dot carlini at oracle dot com
@ 2009-03-09 18:10 ` paolo dot carlini at oracle dot com
  2009-03-09 18:18 ` paolo dot carlini at oracle dot com
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: paolo dot carlini at oracle dot com @ 2009-03-09 18:10 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from paolo dot carlini at oracle dot com  2009-03-09 18:10 -------
The below, not using any header neither C++0x mode (very likely can be further
reduced), doesn't compile with mainline and 4_3-branch, does with EDG-based
compilers in strict mode:

template<bool>
  class __static_assert { };

template<>
  class __static_assert<false>;

template<typename T, typename U>
  struct __are_same { static const bool value = false; };

template<typename T>
  struct __are_same<T, T> { static const bool value = true; };

    class A {

    };

    class B : public A {

    };

    class C {

    };

    namespace gc {

        template <typename T> class member_ptr;
    }

    template <typename T> class weak_ptr {

    public:

        weak_ptr() {}

        template <typename X> weak_ptr(const weak_ptr<X>& v) {}

        weak_ptr(const gc::member_ptr<T>& v);

        template <typename X> weak_ptr& operator=(const weak_ptr<X>& v) {
return *this; }
    };

    namespace gc {

        template <typename T> class member_ptr {

          __static_assert<__are_same<C, T>::value> sa;
       };
    }

int main() {

    weak_ptr<A> ap1;
    weak_ptr<B> bp1;

    ap1 = bp1;
}


-- 

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2009-03-09 18:10:02
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39413


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

* [Bug c++/39413] static_assert and SFINAE
  2009-03-09 17:20 [Bug c++/39413] New: static_assert and SFINAE piotr dot wyderski at gmail dot com
  2009-03-09 17:48 ` [Bug c++/39413] " paolo dot carlini at oracle dot com
  2009-03-09 18:10 ` paolo dot carlini at oracle dot com
@ 2009-03-09 18:18 ` paolo dot carlini at oracle dot com
  2009-03-09 18:33 ` paolo dot carlini at oracle dot com
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: paolo dot carlini at oracle dot com @ 2009-03-09 18:18 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from paolo dot carlini at oracle dot com  2009-03-09 18:17 -------
Volunteers for a better Summary?


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39413


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

* [Bug c++/39413] static_assert and SFINAE
  2009-03-09 17:20 [Bug c++/39413] New: static_assert and SFINAE piotr dot wyderski at gmail dot com
                   ` (2 preceding siblings ...)
  2009-03-09 18:18 ` paolo dot carlini at oracle dot com
@ 2009-03-09 18:33 ` paolo dot carlini at oracle dot com
  2009-03-17 12:55 ` paolo dot carlini at oracle dot com
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: paolo dot carlini at oracle dot com @ 2009-03-09 18:33 UTC (permalink / raw)
  To: gcc-bugs



-- 

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|major                       |normal


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39413


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

* [Bug c++/39413] static_assert and SFINAE
  2009-03-09 17:20 [Bug c++/39413] New: static_assert and SFINAE piotr dot wyderski at gmail dot com
                   ` (4 preceding siblings ...)
  2009-03-17 12:55 ` paolo dot carlini at oracle dot com
@ 2009-03-17 12:55 ` paolo dot carlini at oracle dot com
  2009-11-04 21:27 ` jason at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: paolo dot carlini at oracle dot com @ 2009-03-17 12:55 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from paolo dot carlini at oracle dot com  2009-03-17 12:55 -------
Sorry, CC-ed Jakub instead of Jason ;)


-- 

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|jakub at redhat dot com     |jason at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39413


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

* [Bug c++/39413] static_assert and SFINAE
  2009-03-09 17:20 [Bug c++/39413] New: static_assert and SFINAE piotr dot wyderski at gmail dot com
                   ` (3 preceding siblings ...)
  2009-03-09 18:33 ` paolo dot carlini at oracle dot com
@ 2009-03-17 12:55 ` paolo dot carlini at oracle dot com
  2009-03-17 12:55 ` paolo dot carlini at oracle dot com
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: paolo dot carlini at oracle dot com @ 2009-03-17 12:55 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from paolo dot carlini at oracle dot com  2009-03-17 12:55 -------
Jason, are you willing to help triaging this one?


-- 

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at redhat dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39413


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

* [Bug c++/39413] static_assert and SFINAE
  2009-03-09 17:20 [Bug c++/39413] New: static_assert and SFINAE piotr dot wyderski at gmail dot com
                   ` (5 preceding siblings ...)
  2009-03-17 12:55 ` paolo dot carlini at oracle dot com
@ 2009-11-04 21:27 ` jason at gcc dot gnu dot org
  2009-11-04 22:29 ` jason at gcc dot gnu dot org
  2009-11-04 22:31 ` jason at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-11-04 21:27 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from jason at gcc dot gnu dot org  2009-11-04 21:27 -------
This is not a SFINAE issue, the bug is that we shouldn't be instantiating
member_ptr in the first place in order to resolve the operator= overload.


-- 

jason at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |jason at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2009-03-09 18:10:02         |2009-11-04 21:27:44
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39413


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

* [Bug c++/39413] static_assert and SFINAE
  2009-03-09 17:20 [Bug c++/39413] New: static_assert and SFINAE piotr dot wyderski at gmail dot com
                   ` (6 preceding siblings ...)
  2009-11-04 21:27 ` jason at gcc dot gnu dot org
@ 2009-11-04 22:29 ` jason at gcc dot gnu dot org
  2009-11-04 22:31 ` jason at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-11-04 22:29 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from jason at gcc dot gnu dot org  2009-11-04 22:29 -------
Subject: Bug 39413

Author: jason
Date: Wed Nov  4 22:29:35 2009
New Revision: 153920

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=153920
Log:
        PR c++/39413
        * search.c (lookup_base): Don't complete_type (base).

Added:
    trunk/gcc/testsuite/g++.dg/template/overload11.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/search.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/template/nested3.C


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39413


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

* [Bug c++/39413] static_assert and SFINAE
  2009-03-09 17:20 [Bug c++/39413] New: static_assert and SFINAE piotr dot wyderski at gmail dot com
                   ` (7 preceding siblings ...)
  2009-11-04 22:29 ` jason at gcc dot gnu dot org
@ 2009-11-04 22:31 ` jason at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-11-04 22:31 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from jason at gcc dot gnu dot org  2009-11-04 22:31 -------
Fixed for 4.5.0.


-- 

jason at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.5.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39413


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

end of thread, other threads:[~2009-11-04 22:31 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-09 17:20 [Bug c++/39413] New: static_assert and SFINAE piotr dot wyderski at gmail dot com
2009-03-09 17:48 ` [Bug c++/39413] " paolo dot carlini at oracle dot com
2009-03-09 18:10 ` paolo dot carlini at oracle dot com
2009-03-09 18:18 ` paolo dot carlini at oracle dot com
2009-03-09 18:33 ` paolo dot carlini at oracle dot com
2009-03-17 12:55 ` paolo dot carlini at oracle dot com
2009-03-17 12:55 ` paolo dot carlini at oracle dot com
2009-11-04 21:27 ` jason at gcc dot gnu dot org
2009-11-04 22:29 ` jason at gcc dot gnu dot org
2009-11-04 22:31 ` jason at gcc dot gnu dot org

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).