public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/109703] New: __builtin_unreachable() reached
@ 2023-05-02 19:05 christian.morales.vega at gmail dot com
  2023-05-02 20:10 ` [Bug libstdc++/109703] [13/14 Regression] " pinskia at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: christian.morales.vega at gmail dot com @ 2023-05-02 19:05 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109703

            Bug ID: 109703
           Summary: __builtin_unreachable() reached
           Product: gcc
           Version: 13.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: christian.morales.vega at gmail dot com
  Target Milestone: ---

This
(https://github.com/gcc-mirror/gcc/commit/bf78b43873b0b7e8f9a430df38749b8b61f9c9b8#diff-c8a656ef205ec6452ef0bed111a387dc9e7eb2404fb3222a48f9f93b2460bd55R278)
__builtin_unreachable() is reached using this code

--------------------------------------
#include <boost/algorithm/string/case_conv.hpp>
#include <string>

int main() {
  auto lower = std::string{"0123456789ABCDEF"};
  auto upper = boost::algorithm::to_upper_copy(lower);
}
--------------------------------------

with Boost 1.82.

Doing "g++ -O1 -fsanitize=undefined -o main main.cpp && ./main" results in

/usr/include/c++/13/bits/basic_string.h:278:29: runtime error: execution
reached an unreachable program point

This is with gcc-13.1.1-1.fc38.x86_64 from Fedora 38.


AFAICT the bug is in libstdc++.

During the first iteration, is not until
https://github.com/gcc-mirror/gcc/blob/releases/gcc-13.1.0/libstdc%2B%2B-v3/include/bits/basic_string.tcc#L201
that the data pointer is replaced from the SSO to the heap one; but one line
before, in

https://github.com/gcc-mirror/gcc/blob/releases/gcc-13.1.0/libstdc%2B%2B-v3/include/bits/basic_string.tcc#L200
https://github.com/gcc-mirror/gcc/blob/releases/gcc-13.1.0/libstdc%2B%2B-v3/include/bits/basic_string.h#L293
https://github.com/gcc-mirror/gcc/blob/releases/gcc-13.1.0/libstdc%2B%2B-v3/include/bits/basic_string.h#L275

, it checks whether it should destroy the data based on whether _M_data() ==
_M_local_data().

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2023-07-04 16:41 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-02 19:05 [Bug libstdc++/109703] New: __builtin_unreachable() reached christian.morales.vega at gmail dot com
2023-05-02 20:10 ` [Bug libstdc++/109703] [13/14 Regression] " pinskia at gcc dot gnu.org
2023-05-02 20:11 ` [Bug libstdc++/109703] [12/13/14 " pinskia at gcc dot gnu.org
2023-05-02 20:14 ` pinskia at gcc dot gnu.org
2023-05-02 20:35 ` [Bug libstdc++/109703] [12/13/14 Regression] __builtin_unreachable() reached since r13-6915-gbf78b43873b0b7 redi at gcc dot gnu.org
2023-05-03  2:00 ` pinskia at gcc dot gnu.org
2023-05-03 12:19 ` cvs-commit at gcc dot gnu.org
2023-05-03 12:24 ` cvs-commit at gcc dot gnu.org
2023-05-03 13:24 ` cvs-commit at gcc dot gnu.org
2023-05-03 13:25 ` redi at gcc dot gnu.org
2023-05-04 15:43 ` pinskia at gcc dot gnu.org
2023-05-09 11:22 ` redi at gcc dot gnu.org
2023-07-04 16:41 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).