Repository navigation
Sized operator delete[] gets a different size than operator new[] for a zero-length array new #550
lexx42xxel
started this conversation in
Issue Triage - Compilation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Issue Summary
Version: EDG C/C++ front end 7.0, main at commit 6a6c7f2d6bd8027f1b0c90877b4ba222fbff6642 (2026-11-15).
For
new E[n]withn == 0at run time and a class with a destructor (so there is an array cookie),operator new[]is asked forcookie + 1bytes, but the sizedoperator delete[]is passedcookiebytes. [new.delete.array] requires the same size.Reproducing Source Code
Command-line Options
eccp --c++17 --g++ --exceptions t.cpp -o t && ./t
Type of Issue
[Back End] There is a problem with the generated C code.
Additional Details
Actual output:
Expected: Equal sizes (g++: 8 / 8).
array_new_general(lib_src) bumps a zero-byte request to one byte even when there is a prefix,while the placement, nothrow and aligned paths and the IA-64
delete[]/exception cleanup computen * size + prefix. Bumping only when there is no prefix matches__cxa_vec_new2and g++.The program exits nonzero when the bug is present. A fix with a regression test is ready (branch
fix/zero-length-array-new-sized-delete); a PR will reference this issue.AddressSanitizer
The same bug is detected by AddressSanitizer with this variant, which uses the real allocator /
heap-owning or written members instead of counters:
Report on main (6a6c7f2), addresses elided:
No report with the fix, nor with g++ (
-fsanitize=address).Reproducing (Standard) Configuration(s)
linux-gcc-debug
Reproducing (Non-standard) Configuration
No response
I acknowledge that:
LICENSE.txtfile in my.zipor.tar.gzupload. If I included aLICENSE.txtfile, any tests created using the reproducing source code will be governed by the terms of the license I provided instead.All reactions