Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 31 May 2024 21:22:09 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 279443] LIBCPP assertions are enabled in optimized builds when -DNDEBUG is given to clang
Message-ID:  <bug-279443-227@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D279443

            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=3D251126&action=
=3Dedit
get_executable_filename.cpp

The attached code crashes due to the LIBCPP assertion:

1390=E2=94=82 template <class _Tp, class _Allocator>
1391=E2=94=82 _LIBCPP_CONSTEXPR_SINCE_CXX20 inline _LIBCPP_HIDE_FROM_ABI ty=
pename
vector<_Tp, _Allocator>::reference
1392=E2=94=82 vector<_Tp, _Allocator>::operator[](size_type __n) _NOEXCEPT {
1393=E2=94=9C=E2=94=80> _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n < size(), "=
vector[] index out
of bounds");
1394=E2=94=82   return this->__begin_[__n];
1395=E2=94=82 }

It should be possible to get an address of the end of the std::vector objec=
t,
even though it doesn't point to an allocated byte.

Regular asserts are disabled, but LIBCPP asserts are enabled for some reaso=
n.
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, wh=
ere
the attached testcase comes from.


Clang-18.1.5

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-279443-227>