Previously, the non-const basic_string::data() overload in the standard C++ library was failing to unshare the string, which could lead to inadvertent modification of the string, resulting in misbehavior of the program.
Created attachment 1451986[details]
c++ file to reproduce the problem
Description of problem:
Version-Release number of selected component (if applicable):
gcc --version
gcc (GCC) 7.3.1 20180303 (Red Hat 7.3.1-5)
How reproducible:
always, easy
Steps to Reproduce:
1. g++ -std=c++17 a.cpp
2. ./a.out
3.
Actual results:
BEFORE
s0 = hello world
s1 = hello world
s2 = hello world
AFTER modifying s1
s0 = ello world expecting = hello world
s1 = ello world expecting = ello world
s2 = ello world expecting = hello world
Expected results:
BEFORE
s0 = hello world
s1 = hello world
s2 = hello world
AFTER modifying s1
s0 = hello world expecting = hello world
s1 = ello world expecting = ello world
s2 = hello world expecting = hello world
Additional info:
Hello,
as an additional hint: this bug does not happen with gcc7.3.0 on Ubuntu 18.04 (version gcc (Ubuntu 7.3.0-16ubuntu3) 7.3.0)
Best regards,
Hubert Krause
That's only because Ubuntu's GCC defaults to -D_GLIBCXX_USE_CXX11_ABI=1 and RHEL DTS defaults to -D_GLIBCXX_USE_CXX11_ABI=0
The exact same bug is present in Ubuntu.
It's now been fixed upstream.
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.
For information on the advisory, and where to find the updated
files, follow the link below.
If the solution does not work for you, open a new bug report.
https://access.redhat.com/errata/RHBA-2018:3562
Created attachment 1451986 [details] c++ file to reproduce the problem Description of problem: Version-Release number of selected component (if applicable): gcc --version gcc (GCC) 7.3.1 20180303 (Red Hat 7.3.1-5) How reproducible: always, easy Steps to Reproduce: 1. g++ -std=c++17 a.cpp 2. ./a.out 3. Actual results: BEFORE s0 = hello world s1 = hello world s2 = hello world AFTER modifying s1 s0 = ello world expecting = hello world s1 = ello world expecting = ello world s2 = ello world expecting = hello world Expected results: BEFORE s0 = hello world s1 = hello world s2 = hello world AFTER modifying s1 s0 = hello world expecting = hello world s1 = ello world expecting = ello world s2 = hello world expecting = hello world Additional info: