public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/107528] New: constexpr evaluator doesn't check for deallocate of mismatched size
@ 2022-11-05 0:56 vanyacpp at gmail dot com
2022-11-05 2:31 ` [Bug c++/107528] " de34 at live dot cn
0 siblings, 1 reply; 2+ messages in thread
From: vanyacpp at gmail dot com @ 2022-11-05 0:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107528
Bug ID: 107528
Summary: constexpr evaluator doesn't check for deallocate of
mismatched size
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: vanyacpp at gmail dot com
Target Milestone: ---
This functions causes undefined behavior and should not be evaluated at
compile-time.
The problem is the second argument of `deallocate` function (number of objects
to deallocate). It must be equal to the number of objects that were allocated.
#include <memory>
constexpr int foo()
{
std::allocator<int> alloc;
int* p = alloc.allocate(1);
alloc.deallocate(p, 3);
return 42;
}
static_assert(foo() == 42);
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/107528] constexpr evaluator doesn't check for deallocate of mismatched size
2022-11-05 0:56 [Bug c++/107528] New: constexpr evaluator doesn't check for deallocate of mismatched size vanyacpp at gmail dot com
@ 2022-11-05 2:31 ` de34 at live dot cn
0 siblings, 0 replies; 2+ messages in thread
From: de34 at live dot cn @ 2022-11-05 2:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107528
Jiang An <de34 at live dot cn> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |de34 at live dot cn
--- Comment #1 from Jiang An <de34 at live dot cn> ---
Currently it's unspecified whether this UB results in constant evaluation
failure, because this is only caused by the specification in the standard
library part (see [expr.const]).
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-11-05 2:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-05 0:56 [Bug c++/107528] New: constexpr evaluator doesn't check for deallocate of mismatched size vanyacpp at gmail dot com
2022-11-05 2:31 ` [Bug c++/107528] " de34 at live dot cn
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).