[Bug 279443] LIBCPP assertions are enabled in optimized builds when -DNDEBUG is given to clang
Date: Fri, 31 May 2024 21:22:09 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=279443
Bug ID: 279443
Summary: LIBCPP assertions are enabled in optimized builds when
-DNDEBUG is given to clang
Product: Base System
Version: 14.0-STABLE
Hardware: Any
OS: Any
Status: New
Severity: Affects Only Me
Priority: ---
Component: misc
Assignee: bugs@FreeBSD.org
Reporter: yuri@freebsd.org
Attachment #251126 text/plain
mime type:
Created attachment 251126
--> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=251126&action=edit
get_executable_filename.cpp
The attached code crashes due to the LIBCPP assertion:
1390│ template <class _Tp, class _Allocator>
1391│ _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI typename
vector<_Tp, _Allocator>::reference
1392│ vector<_Tp, _Allocator>::operator[](size_type __n) _NOEXCEPT {
1393├─> _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n < size(), "vector[] index out
of bounds");
1394│ return this->__begin_[__n];
1395│ }
It should be possible to get an address of the end of the std::vector object,
even though it doesn't point to an allocated byte.
Regular asserts are disabled, but LIBCPP asserts are enabled for some reason.
It is unclear to me when LIBCPP assertions should be enabled, but optimized
runs with -DNDEBUG should definitely have them disabled.
Enabled assertions also cause the performance degradation.
This assertion caused the discovery of a real bug in the devel/hpx port, where
the attached testcase comes from.
Clang-18.1.5
--
You are receiving this mail because:
You are the assignee for the bug.