public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/65290] New: [C++11] operator new(std::size_t, const std::nothrow_t&) should call operator new(std::size_t)
@ 2015-03-03 4:11 kariya_mitsuru at hotmail dot com
2015-03-03 10:02 ` [Bug libstdc++/65290] " redi at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: kariya_mitsuru at hotmail dot com @ 2015-03-03 4:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65290
Bug ID: 65290
Summary: [C++11] operator new(std::size_t, const
std::nothrow_t&) should call operator new(std::size_t)
Product: gcc
Version: 5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: kariya_mitsuru at hotmail dot com
Created attachment 34930
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34930&action=edit
g++ -v
Please see the sample code below.
========================== sample code ==========================
#include <iostream>
#include <new>
void* operator new(std::size_t)
{
throw std::bad_alloc();
}
int main()
{
int* p = new(std::nothrow) int;
std::cout << std::boolalpha << (p == nullptr) << std::endl;
delete p;
}
========================== sample code ==========================
========================== output ==========================
false
========================== output ==========================
cf. http://melpon.org/wandbox/permlink/LTq0gqETftUEvWK0
The C++11 standard 18.6.1.1[new.delete.single]/p.8 says,
Default behavior: Calls operator new(size). If the call returns normally,
returns the result of that call. Otherwise, returns a null pointer.
This description was changed in C++11(see LWG DR206).
cf. http://cplusplus.github.io/LWG/lwg-defects.html#206
So, I think that the sample code above should output
========================== output ==========================
true
========================== output ==========================
I am not sure whether operator new(std::size_t, const std::nothrow_t&) should
call operator new(std::size_t) in C++03 mode.
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug libstdc++/65290] [C++11] operator new(std::size_t, const std::nothrow_t&) should call operator new(std::size_t)
2015-03-03 4:11 [Bug libstdc++/65290] New: [C++11] operator new(std::size_t, const std::nothrow_t&) should call operator new(std::size_t) kariya_mitsuru at hotmail dot com
@ 2015-03-03 10:02 ` redi at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: redi at gcc dot gnu.org @ 2015-03-03 10:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65290
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2015-03-03
Ever confirmed|0 |1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-03-03 10:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-03 4:11 [Bug libstdc++/65290] New: [C++11] operator new(std::size_t, const std::nothrow_t&) should call operator new(std::size_t) kariya_mitsuru at hotmail dot com
2015-03-03 10:02 ` [Bug libstdc++/65290] " redi 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).