[Bug 279443] LIBCPP assertions are enabled in optimized builds when -DNDEBUG is given to clang
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 31 May 2024 22:28:48 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=279443
Mark Millard <marklmi26-fbsd@yahoo.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |marklmi26-fbsd@yahoo.com
--- Comment #1 from Mark Millard <marklmi26-fbsd@yahoo.com> ---
I tried the code that is based on:
std::copy(
&buf[0],
&buf[cb], // !!! ASSERTs HERE !!!
std::back_inserter(r)
);
via:
# c++ -g get_executable_filename.cpp
# gdb a.out
. . .
Reading symbols from a.out...
(gdb) run
Starting program: /usr/home/root/c_tests/a.out
Program received signal SIGILL, Illegal instruction.
Privileged opcode.
0x0000000000203faa in std::__1::vector<char, std::__1::allocator<char>
>::operator[][abi:se180100](unsigned long) (this=0x7fffffffe940, __n=29) at
/usr/include/c++/v1/vector:1393
1393 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n < size(), "vector[] index out
of bounds");
Then I tried that sequence based on:
std::copy(
&buf[0],
//&buf[cb], // !!! ASSERTs HERE !!!
&buf[0] + cb,
std::back_inserter(r)
);
# c++ -g get_executable_filename.cpp
# gdb a.out
. . .
Reading symbols from a.out...
(gdb) run
Starting program: /usr/home/root/c_tests/a.out
/usr/home/root/c_tests/a.out
[Inferior 1 (process 66199) exited normally]
I'm not so sure that C++ defines &buf[cb] as equivalent to &buf[0] + cb
for std::contiguous_iterator contexts relative to all issues.
cppreference.com reports for std::contiguous_iterator :
QUOTE
Semantic requirements
Let a and b be dereferenceable iterators and c be a non-dereferenceable
iterator of type I such that b is reachable from a and c is reachable from b.
The type I models contiguous_iterator only if all the concepts it subsumes are
modeled and:
std::to_address(a) == std::addressof(*a),
std::to_address(b) == std::to_address(a) + std::iter_difference_t<I>(b - a),
and
std::to_address(c) == std::to_address(a) + std::iter_difference_t<I>(c - a).
END QUOTE
&buf[0] + cb notation does avoid any suggestion of dereferencing buf[cb] at
any stage.
--
You are receiving this mail because:
You are the assignee for the bug.