public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/51222] New: [C++11][SFINAE] Unevaluated combined delete new expression completely broken
@ 2011-11-19 18:39 daniel.kruegler at googlemail dot com
  2011-11-20  0:27 ` [Bug c++/51222] " paolo.carlini at oracle dot com
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2011-11-19 18:39 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 51222
           Summary: [C++11][SFINAE] Unevaluated combined delete new
                    expression completely broken
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: daniel.kruegler@googlemail.com
                CC: jason@gcc.gnu.org


The following problem became obvious to me when I recently tried to provide a
both simpler and more general library emulation of is_constructible.

gcc 4.7 20111112 (experimental) in C++11 mode rejects the following code:

//---
template<class T>
struct add_rref {
  typedef T&& type;
};

template<>
struct add_rref<void> {
  typedef void type;
};

template<class T>
typename add_rref<T>::type declval();

template<class T, class U, class =
  decltype(::delete ::new T(declval<U>()))
>
auto f(int) -> char;

template<class, class>
auto f(...) -> char(&)[2];

template<class T, class =
  decltype(::delete ::new T())
>
auto g(int) -> char;

template<class>
auto g(...) -> char(&)[2];

struct C { };

struct A {
  virtual ~A() = 0;
};

struct D1 {
  D1() = delete;
};

struct D2 {
  ~D2() = delete;
};

static_assert(sizeof(g<void>(0)) == 2, "Ouch");
static_assert(sizeof(g<void()>(0)) == 2, "Ouch");
static_assert(sizeof(g<void() const>(0)) == 2, "Ouch");
static_assert(sizeof(g<A>(0)) == 2, "Ouch");
static_assert(sizeof(g<D1>(0)) == 2, "Ouch");
static_assert(sizeof(g<D2>(0)) == 2, "Ouch");
static_assert(sizeof(g<int&>(0)) == 2, "Ouch");
static_assert(sizeof(g<int&&>(0)) == 2, "Ouch");
static_assert(sizeof(g<void(&)()>(0)) == 2, "Ouch");
static_assert(sizeof(g<void(&&)()>(0)) == 2, "Ouch");
static_assert(sizeof(f<void, void>(0)) == 2, "Ouch");
static_assert(sizeof(f<void(), void()>(0)) == 2, "Ouch");
static_assert(sizeof(f<void() const, void() const>(0)) == 2, "Ouch");
static_assert(sizeof(f<int, void>(0)) == 2, "Ouch");
static_assert(sizeof(f<void, int>(0)) == 2, "Ouch");
static_assert(sizeof(f<C, void>(0)) == 2, "Ouch");
static_assert(sizeof(f<C, int>(0)) == 2, "Ouch");
static_assert(sizeof(f<int&, int&>(0)) == 2, "Ouch");
static_assert(sizeof(f<int&&, int&&>(0)) == 2, "Ouch");
static_assert(sizeof(f<void(&)(), void(&)()>(0)) == 2, "Ouch");
static_assert(sizeof(f<void(&&)(), void(&&)()>(0)) == 2, "Ouch");
//---

All static assertions fail, but they shouldn't. This is very unfortunate,
because above test expressions are extremely useful for emulating an effective
variable definition including destruction semantics.

The test code should be accepted.


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

* [Bug c++/51222] [C++11][SFINAE] Unevaluated combined delete new expression completely broken
  2011-11-19 18:39 [Bug c++/51222] New: [C++11][SFINAE] Unevaluated combined delete new expression completely broken daniel.kruegler at googlemail dot com
@ 2011-11-20  0:27 ` paolo.carlini at oracle dot com
  2011-11-21  8:08 ` daniel.kruegler at googlemail dot com
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-11-20  0:27 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Blocks|                            |51185

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-11-19 23:36:59 UTC ---
Ouch, indeed. Then let's mark this as blocking the library issue (if Daniel in
the meanwhile you can figure out a workaround we can remove the blockage)


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

* [Bug c++/51222] [C++11][SFINAE] Unevaluated combined delete new expression completely broken
  2011-11-19 18:39 [Bug c++/51222] New: [C++11][SFINAE] Unevaluated combined delete new expression completely broken daniel.kruegler at googlemail dot com
  2011-11-20  0:27 ` [Bug c++/51222] " paolo.carlini at oracle dot com
@ 2011-11-21  8:08 ` daniel.kruegler at googlemail dot com
  2011-11-22 22:34 ` paolo.carlini at oracle dot com
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2011-11-21  8:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Daniel Krügler <daniel.kruegler at googlemail dot com> 2011-11-21 07:51:49 UTC ---
When fixing this problem, I suggest to add the following tests as well, which
also fail currently (In previous builds sometimes one of these forms worked
when the other failed):

//---
template<class T>
struct add_rref {
  typedef T&& type;
};

template<>
struct add_rref<void> {
  typedef void type;
};

template<class T>
typename add_rref<T>::type declval();

template<class T, class U>
auto f2(int) -> decltype(::delete ::new T(declval<U>()), char());

template<class, class>
auto f2(...) -> char(&)[2];

template<class T>
auto g2(int) -> decltype(::delete ::new T(), char());

template<class>
auto g2(...) -> char(&)[2];

struct C { };

struct A {
  virtual ~A() = 0;
};

struct D1 {
  D1() = delete;
};

struct D2 {
  ~D2() = delete;
};

static_assert(sizeof(g2<void>(0)) == 2, "Ouch");
static_assert(sizeof(g2<void()>(0)) == 2, "Ouch");
static_assert(sizeof(g2<void() const>(0)) == 2, "Ouch");
static_assert(sizeof(g2<A>(0)) == 2, "Ouch");
static_assert(sizeof(g2<D1>(0)) == 2, "Ouch");
static_assert(sizeof(g2<D2>(0)) == 2, "Ouch");
static_assert(sizeof(g2<int&>(0)) == 2, "Ouch");
static_assert(sizeof(g2<int&&>(0)) == 2, "Ouch");
static_assert(sizeof(g2<void(&)()>(0)) == 2, "Ouch");
static_assert(sizeof(g2<void(&&)()>(0)) == 2, "Ouch");
static_assert(sizeof(f2<void, void>(0)) == 2, "Ouch");
static_assert(sizeof(f2<void(), void()>(0)) == 2, "Ouch");
static_assert(sizeof(f2<void() const, void() const>(0)) == 2, "Ouch");
static_assert(sizeof(f2<int, void>(0)) == 2, "Ouch");
static_assert(sizeof(f2<void, int>(0)) == 2, "Ouch");
static_assert(sizeof(f2<C, void>(0)) == 2, "Ouch");
static_assert(sizeof(f2<C, int>(0)) == 2, "Ouch");
static_assert(sizeof(f2<int&, int&>(0)) == 2, "Ouch");
static_assert(sizeof(f2<int&&, int&&>(0)) == 2, "Ouch");
static_assert(sizeof(f2<void(&)(), void(&)()>(0)) == 2, "Ouch");
static_assert(sizeof(f2<void(&&)(), void(&&)()>(0)) == 2, "Ouch");
//---


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

* [Bug c++/51222] [C++11][SFINAE] Unevaluated combined delete new expression completely broken
  2011-11-19 18:39 [Bug c++/51222] New: [C++11][SFINAE] Unevaluated combined delete new expression completely broken daniel.kruegler at googlemail dot com
  2011-11-20  0:27 ` [Bug c++/51222] " paolo.carlini at oracle dot com
  2011-11-21  8:08 ` daniel.kruegler at googlemail dot com
@ 2011-11-22 22:34 ` paolo.carlini at oracle dot com
  2012-05-24 12:32 ` paolo.carlini at oracle dot com
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-11-22 22:34 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011-11-22
             Blocks|51185                       |
     Ever Confirmed|0                           |1

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-11-22 21:50:48 UTC ---
Confirmed indeed (and cleared Blocks field, PR51185 is fixed anyway).


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

* [Bug c++/51222] [C++11][SFINAE] Unevaluated combined delete new expression completely broken
  2011-11-19 18:39 [Bug c++/51222] New: [C++11][SFINAE] Unevaluated combined delete new expression completely broken daniel.kruegler at googlemail dot com
                   ` (2 preceding siblings ...)
  2011-11-22 22:34 ` paolo.carlini at oracle dot com
@ 2012-05-24 12:32 ` paolo.carlini at oracle dot com
  2012-06-11 16:02 ` paolo.carlini at oracle dot com
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-05-24 12:32 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|unassigned at gcc dot       |paolo.carlini at oracle dot
                   |gnu.org                     |com
   Target Milestone|---                         |4.8.0

--- Comment #4 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-05-24 12:16:54 UTC ---
I worked on this and a patch is essentially ready, AFAICS. But there are ABI
implications waiting to be resolved, if I understand correctly.


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

* [Bug c++/51222] [C++11][SFINAE] Unevaluated combined delete new expression completely broken
  2011-11-19 18:39 [Bug c++/51222] New: [C++11][SFINAE] Unevaluated combined delete new expression completely broken daniel.kruegler at googlemail dot com
                   ` (3 preceding siblings ...)
  2012-05-24 12:32 ` paolo.carlini at oracle dot com
@ 2012-06-11 16:02 ` paolo.carlini at oracle dot com
  2012-08-31  2:50 ` jason at gcc dot gnu.org
  2012-08-31 15:03 ` jason at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-06-11 16:02 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-06-11 16:02:40 UTC ---
Last posted version:

  http://gcc.gnu.org/ml/gcc-patches/2012-05/msg00157.html


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

* [Bug c++/51222] [C++11][SFINAE] Unevaluated combined delete new expression completely broken
  2011-11-19 18:39 [Bug c++/51222] New: [C++11][SFINAE] Unevaluated combined delete new expression completely broken daniel.kruegler at googlemail dot com
                   ` (4 preceding siblings ...)
  2012-06-11 16:02 ` paolo.carlini at oracle dot com
@ 2012-08-31  2:50 ` jason at gcc dot gnu.org
  2012-08-31 15:03 ` jason at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu.org @ 2012-08-31  2:50 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Jason Merrill <jason at gcc dot gnu.org> 2012-08-31 02:50:35 UTC ---
Author: jason
Date: Fri Aug 31 02:50:28 2012
New Revision: 190830

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=190830
Log:
    PR c++/50545
    PR c++/51222
    * pt.c (instantiation_dependent_r): New.
    (instantiation_dependent_expression_p): New.
    (value_dependent_expression_p): Use it.  SCOPE_REF is always dependent.
    * semantics.c (finish_decltype_type): Use it.
    * cp-tree.h: Declare it.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/decltype40.C
    trunk/gcc/testsuite/g++.dg/cpp0x/decltype41.C
    trunk/gcc/testsuite/g++.dg/cpp0x/decltype42.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/cp-tree.h
    trunk/gcc/cp/pt.c
    trunk/gcc/cp/semantics.c


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

* [Bug c++/51222] [C++11][SFINAE] Unevaluated combined delete new expression completely broken
  2011-11-19 18:39 [Bug c++/51222] New: [C++11][SFINAE] Unevaluated combined delete new expression completely broken daniel.kruegler at googlemail dot com
                   ` (5 preceding siblings ...)
  2012-08-31  2:50 ` jason at gcc dot gnu.org
@ 2012-08-31 15:03 ` jason at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu.org @ 2012-08-31 15:03 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #7 from Jason Merrill <jason at gcc dot gnu.org> 2012-08-31 15:03:09 UTC ---
Fixed.


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

end of thread, other threads:[~2012-08-31 15:03 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-19 18:39 [Bug c++/51222] New: [C++11][SFINAE] Unevaluated combined delete new expression completely broken daniel.kruegler at googlemail dot com
2011-11-20  0:27 ` [Bug c++/51222] " paolo.carlini at oracle dot com
2011-11-21  8:08 ` daniel.kruegler at googlemail dot com
2011-11-22 22:34 ` paolo.carlini at oracle dot com
2012-05-24 12:32 ` paolo.carlini at oracle dot com
2012-06-11 16:02 ` paolo.carlini at oracle dot com
2012-08-31  2:50 ` jason at gcc dot gnu.org
2012-08-31 15:03 ` jason at gcc dot gnu.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).