public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/48872] New: [C++0x][noexcept] Placement-new problem with non-empty arguments
@ 2011-05-04 15:35 daniel.kruegler at googlemail dot com
  2011-05-04 17:44 ` [Bug c++/48872] " daniel.kruegler at googlemail dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2011-05-04 15:35 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: [C++0x][noexcept] Placement-new problem with non-empty
                    arguments
           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@redhat.com


gcc 4.7.0 20110430 (experimental) in C++0x mode rejects the following program:

//--------------
#include <new>

struct U {};

template<class T>
T&& create();

const bool b = noexcept(::new (((void*) 0)) U(create<U&&>()));
static_assert(b, "Ouch"); // #

int main() {}
//--------------

At the line marked with # the static_assert fires. The same problem occurs, if
the initializer of U is e.g. create<U&>() or create<const U&>(), but a program
with an empty initializer like

const bool b = noexcept(::new (((void*) 0)) U());

is accepted. In either case no operation which potentially throws an exception
is called, therefore the program should be accepted.


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

* [Bug c++/48872] [C++0x][noexcept] Placement-new problem with non-empty arguments
  2011-05-04 15:35 [Bug c++/48872] New: [C++0x][noexcept] Placement-new problem with non-empty arguments daniel.kruegler at googlemail dot com
@ 2011-05-04 17:44 ` daniel.kruegler at googlemail dot com
  2011-05-04 17:54 ` paolo.carlini at oracle dot com
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2011-05-04 17:44 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Daniel Krügler <daniel.kruegler at googlemail dot com> 2011-05-04 17:38:16 UTC ---
(In reply to comment #0)

<sigh> an error happended when I tryied to transform my original example (using
std::declval) to a form with a minimum of library support. So let me provide
this fixed example and please ignore the first example:

gcc 4.7.0 20110430 (experimental) in C++0x mode rejects the following program:

//---------------
#include <new>

template<class T>
T&& create() noexcept;

struct U {
  ~U() noexcept(false);
};

constexpr bool b = noexcept(::new ((void*) 0) U(create<U&&>()));

static_assert(b, "Ouch"); // #

int main() {}
//---------------

The compiler rejects the line marked with # because of an assertion failure.
This happens in all cases where an U is placement-constructed with arguments as
with create<U&>() or with create<const U&>(). The example is accpted when only
value-initialized, like this:

constexpr bool b = noexcept(::new ((void*) 0) U());

This example demonstrates that the compiler seems to create a temporary in the
affected cases, so this is just another aspect of #48873.


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

* [Bug c++/48872] [C++0x][noexcept] Placement-new problem with non-empty arguments
  2011-05-04 15:35 [Bug c++/48872] New: [C++0x][noexcept] Placement-new problem with non-empty arguments daniel.kruegler at googlemail dot com
  2011-05-04 17:44 ` [Bug c++/48872] " daniel.kruegler at googlemail dot com
@ 2011-05-04 17:54 ` paolo.carlini at oracle dot com
  2011-05-04 18:15 ` daniel.kruegler at googlemail dot com
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-05-04 17:54 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-05-04 17:53:25 UTC ---
As I side remark, I'm not sure to understand why your testcases often include
an 'int main { }' line, I don't think are about link-time problems, no? If you
compile only what's the main for?


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

* [Bug c++/48872] [C++0x][noexcept] Placement-new problem with non-empty arguments
  2011-05-04 15:35 [Bug c++/48872] New: [C++0x][noexcept] Placement-new problem with non-empty arguments daniel.kruegler at googlemail dot com
  2011-05-04 17:44 ` [Bug c++/48872] " daniel.kruegler at googlemail dot com
  2011-05-04 17:54 ` paolo.carlini at oracle dot com
@ 2011-05-04 18:15 ` daniel.kruegler at googlemail dot com
  2011-05-04 18:44 ` paolo.carlini at oracle dot com
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2011-05-04 18:15 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Daniel Krügler <daniel.kruegler at googlemail dot com> 2011-05-04 17:59:21 UTC ---
(In reply to comment #2)
> As I side remark, I'm not sure to understand why your testcases often include
> an 'int main { }' line, I don't think are about link-time problems, no? If you
> compile only what's the main for?

I will try to reduce that in the future for bug reports. I'm still in standard
mode when doing this to ensure that the program is well-formed and
well-defined. Partial programs seem ok here, if I understand you correctly.


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

* [Bug c++/48872] [C++0x][noexcept] Placement-new problem with non-empty arguments
  2011-05-04 15:35 [Bug c++/48872] New: [C++0x][noexcept] Placement-new problem with non-empty arguments daniel.kruegler at googlemail dot com
                   ` (2 preceding siblings ...)
  2011-05-04 18:15 ` daniel.kruegler at googlemail dot com
@ 2011-05-04 18:44 ` paolo.carlini at oracle dot com
  2011-05-05  7:20 ` daniel.kruegler at googlemail dot com
  2011-05-05 15:40 ` jason at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-05-04 18:44 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |paolo.carlini at oracle dot
                   |                            |com

--- Comment #4 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-05-04 18:27:21 UTC ---
To be clear, this is what I meant: do you want to test a compile-time,
link-time, or run-time problem (to name the most common categories)? Often the
former, I suppose, and indeed this is the way your testcases ended up being
used in the testsuite in the past in the majority of the cases. In that case no
need to add a main (somebody will certainly remove it anyway). For more
details:

  http://gcc.gnu.org/wiki/HowToPrepareATestcase


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

* [Bug c++/48872] [C++0x][noexcept] Placement-new problem with non-empty arguments
  2011-05-04 15:35 [Bug c++/48872] New: [C++0x][noexcept] Placement-new problem with non-empty arguments daniel.kruegler at googlemail dot com
                   ` (3 preceding siblings ...)
  2011-05-04 18:44 ` paolo.carlini at oracle dot com
@ 2011-05-05  7:20 ` daniel.kruegler at googlemail dot com
  2011-05-05 15:40 ` jason at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2011-05-05  7:20 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Daniel Krügler <daniel.kruegler at googlemail dot com> 2011-05-05 07:15:12 UTC ---
(In reply to comment #1)

More information by a different example: It seems that the problem case reacts
very sensitive to minor modifications of the class. The following provides a
slightly different version of the previous example:

//---------------
#include <new>

//#define ADD_CTOR

struct U2 {
#ifdef ADD_CTOR
  U2(int) noexcept;
#endif
  ~U2() noexcept(false);
};

template<class T>
T&& create() noexcept;

const bool b = noexcept(::new (((void*) 0)) U2(create<U2&&>()));
static_assert(b, "Ouch"); // #
//---------------

As written, the same static assert violation occurs as in the example provided
by comment 1. But if the line

//#define ADD_CTOR

is uncommented *without any further changes* the program becomes accepted.
Somehow the addition of the user-provided constructor - even though it is not
used here - influences the evaluation of the noexcept expression.


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

* [Bug c++/48872] [C++0x][noexcept] Placement-new problem with non-empty arguments
  2011-05-04 15:35 [Bug c++/48872] New: [C++0x][noexcept] Placement-new problem with non-empty arguments daniel.kruegler at googlemail dot com
                   ` (4 preceding siblings ...)
  2011-05-05  7:20 ` daniel.kruegler at googlemail dot com
@ 2011-05-05 15:40 ` jason at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: jason at gcc dot gnu.org @ 2011-05-05 15:40 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |jason at gcc dot gnu.org
         Resolution|                            |DUPLICATE
   Target Milestone|---                         |4.7.0

--- Comment #6 from Jason Merrill <jason at gcc dot gnu.org> 2011-05-05 15:29:03 UTC ---
Resolved by the same fix as 48873.

*** This bug has been marked as a duplicate of bug 48873 ***


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

end of thread, other threads:[~2011-05-05 15:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-04 15:35 [Bug c++/48872] New: [C++0x][noexcept] Placement-new problem with non-empty arguments daniel.kruegler at googlemail dot com
2011-05-04 17:44 ` [Bug c++/48872] " daniel.kruegler at googlemail dot com
2011-05-04 17:54 ` paolo.carlini at oracle dot com
2011-05-04 18:15 ` daniel.kruegler at googlemail dot com
2011-05-04 18:44 ` paolo.carlini at oracle dot com
2011-05-05  7:20 ` daniel.kruegler at googlemail dot com
2011-05-05 15:40 ` 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).