eclipse-score / eclipse-score/baselibs

False positive `-Wmismatched-new-delete` with placement new in QNX 8.0 compiler

Open
#48 1 comment 0 reactions 1 assignee Claimed by @Rutik7 View on GitHub
Dominant language
C++
Stars
26
Forks
85
Avg merge
2d 13h
Merged PRs (30d)
47

Description

The QNX 8.0 compiler incorrectly reports `-Wmismatched-new-delete` warnings when using placement new. This appears to be a false positive, as the code correctly uses placement new without any actual mismatched new/delete operators. No such warning is emitted with the GCC compiler.

A reproducer in godbolt: https://godbolt.org/z/63fYE1jv8

Several places in baselibs are affected. For example the `score/memory/shared`:
```
$ bazel build --credential_helper="*.qnx.com=$(pwd)/.git/tools/qnx_credential_helper.py" --config=bl-x86_64-qnx //score/memory/...
INFO: Analyzed 82 targets (0 packages loaded, 0 targets configured).
ERROR: baselibs/score/memory/shared/fake/BUILD:15:11: Compiling score/memory/shared/fake/my_bounded_memory_resource.cpp failed: (Exit 1): q++ failed: error executing CppCompile command (from target //score/memory/shared/fake:fake_memory_resources) external/score_toolchains_qnx++toolchains_qnx+toolchains_qnx_sdp/host/linux/x86_64/usr/bin/q++ -V12.2.0,gcc_ntox86_64 -fno-canonical-system-headers -D_QNX_SOURCE '-std=c++17' ... (remaining 27 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
score/memory/shared/fake/my_bounded_memory_resource.cpp: In member function 'score::memory::shared::MemoryResourceProxy* score::memory::shared::test::MyBoundedMemoryResource::AllocateMemoryResourceProxy(uint64_t)':
score/memory/shared/fake/my_bounded_memory_resource.cpp:127:64: error: 'void operator delete(void*, void*)' called on pointer returned from a mismatched allocation function [-Werror=mismatched-new-delete]
127 | return new (storage) MemoryResourceProxy(memory_resource_id);
| ^
score/memory/shared/fake/my_bounded_memory_resource.cpp:127:64: note: returned from 'void* operator new(size_t, void*)'
cc1plus: all warnings being treated as errors
INFO: Elapsed time: 1.526s, Critical Path: 1.25s
INFO: 7 processes: 5 internal, 2 processwrapper-sandbox.
ERROR: Build did NOT complete successfully
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.