From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3CFD83858C2B; Sat, 5 Nov 2022 00:56:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3CFD83858C2B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667609769; bh=DTwgbeX5AeAX8DnEJxLUEh/CahuMaeE0NthnlEo5FJU=; h=From:To:Subject:Date:From; b=sHRRAc0ILGBa4BrScxPce26XJV1L/yo+twJFWkYCe/fJNMqbts1zFP3ID5IUvHz8H 6DjXsGJhkHEDMzkULxWzptHKobMkUht6EFmnCDWrqab7nL4wdHajXQNh99hv3EO3ny izeUojxGIszHXtCjlCXdTRoR9F9rdWvsEHipZGKY= From: "vanyacpp at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/107528] New: constexpr evaluator doesn't check for deallocate of mismatched size Date: Sat, 05 Nov 2022 00:56:08 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: vanyacpp at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107528 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 obje= cts to deallocate). It must be equal to the number of objects that were allocat= ed. #include constexpr int foo() { std::allocator alloc; int* p =3D alloc.allocate(1); alloc.deallocate(p, 3); return 42; } static_assert(foo() =3D=3D 42);=