Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1591823

Summary: c++17 data() member function of std::string undesired side effects
Product: Red Hat Developer Toolset Reporter: Hubert Krause <hubert.krause>
Component: gccAssignee: Marek Polacek <mpolacek>
Status: CLOSED ERRATA QA Contact: Michael Petlan <mpetlan>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: DTS 7.1 RHEL 7CC: jakub, jwakely, kanderso, law, mcermak, mnewsome, mpetlan, ohudlick
Target Milestone: alpha   
Target Release: 7.1   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: devtoolset-8-gcc-8.1.1-5.el7 Doc Type: Bug Fix
Doc Text:
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.
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-11-13 08:38:30 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
c++ file to reproduce the problem none

Description Hubert Krause 2018-06-15 16:12:40 UTC
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:

Comment 2 Hubert Krause 2018-06-18 08:29:12 UTC
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

Comment 3 Jonathan Wakely 2018-06-18 11:07:42 UTC
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.

Comment 4 Marek Polacek 2018-07-13 18:12:15 UTC
Fixed in DTS 8:
# g++ d.cc -std=c++17 -D_GLIBCXX_USE_CXX11_ABI=1; ./a.out
# g++ d.cc -std=c++17 -D_GLIBCXX_USE_CXX11_ABI=0; ./a.out

Comment 6 Michael Petlan 2018-11-06 19:42:05 UTC
VERIFIED for devtoolset-8-gcc-8.2.1-3.

Comment 8 errata-xmlrpc 2018-11-13 08:38:30 UTC
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