-
Bug
-
Resolution: Duplicate
-
Undefined
-
None
-
rhel-9.7
-
None
-
None
-
Low
-
rhel-pt-gcc-2
-
None
-
False
-
False
-
-
None
-
None
-
None
-
None
-
Unspecified
-
Unspecified
-
Unspecified
-
None
What were you trying to do that didn't work?
Compile third-party code that makes use of `std::get_time(&t, "%b")` (See reproducer code below)
In gcc 15.1.1, at -O1, everything works as expected.
In gcc 15.1.1, at -O2, the istringstream.fail() returns true after calling std::get_time(&t, "%b") in a istringstream that has been imbued with an empty locale (or not imbued and following the default "LANG=en_US.utf8", in either case.
We have narrowed this down to the `-fipa-sra` option that is included in the `-O2` optimizations as causing the issue.
Using gcc-toolset-14-gcc-c+-14.2.1-12.el9_7.x86_64, `scl enable gcc-toolset-14 – g+ -std=c++17` with either `-O2` or `-O1` works as expected (returns 0)
Using gcc-toolset-15-gcc-c+-15.1.1-2.4.el9.x86_64, compiling as `scl enable gcc-toolset-15 – g+ -std=c++17` with `-O1` and `-O2 -fno-ipa-sra` works as expected (returns 0)
Using gcc-toolset-15-gcc-c+-15.1.1-2.4.el9.x86_64, compiling as `scl enable gcc-toolset-15 – g+ -std=c++17` with `-O2` and `-O1 -fipa-sra` FAILS (returns 1)
Using gcc-toolset-15-gcc-c+15.1.1-2.5.el10.x86_64, compiling as `gcc-toolset-15-env g+ -std=c++17` with `-O2` works as expected (returns 0)
Using the `x86-64 gcc 15.1 installation on godbolt.org does not seem to have this error (reproducer code returns 0 as expected with both -O1 and -O2), so it seems to be specific to the gcc-toolset-15
(The godbolt compiler appears to be gcc 15.1.0, configured with ../gcc-15.1.0/configure -prefix=/opt/compiler-explorer/gcc-build/staging --enable-libstdcxx-backtrace=yes --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --disable-bootstrap --enable-multiarch --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --enable-clocale=gnu --enable-languages=c,c+,fortran,ada,objc,obj-c+,go,d,m2,rust,cobol --enable-ld=yes --enable-gold=yes --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-linker-build-id --enable-lto --enable-plugins --enable-threads=posix --with-pkgversion=Compiler-Explorer-Build-gcc-binutils-2.44)
What is the impact of this issue to you?
Customer code that uses std::get_time to parse full-name Month strings (e.g. January, April) will fail to execute correctly, possibly other knock-on issues.
Please provide the package NVR for which the bug is seen:
gcc-toolset-15-runtime-15.0-9.el9.x86_64
gcc-toolset-15-libstdc++-devel-15.1.1-2.4.el9.x86_64
gcc-toolset-15-binutils-2.44-3.el9_7.1.x86_64
gcc-toolset-15-gcc-15.1.1-2.4.el9.x86_64
gcc-toolset-15-gcc-c++-15.1.1-2.4.el9.x86_64
gcc-toolset-15-libquadmath-devel-15.1.1-2.4.el9.x86_64
gcc-toolset-15-gcc-gfortran-15.1.1-2.4.el9.x86_64
gcc-toolset-15-libasan-devel-15.1.1-2.4.el9.x86_64
gcc-toolset-15-liblsan-devel-15.1.1-2.4.el9.x86_64
gcc-toolset-15-libtsan-devel-15.1.1-2.4.el9.x86_64
gcc-toolset-15-libubsan-devel-15.1.1-2.4.el9.x86_64
glibc-minimal-langpack-2.34-231.el9_7.2.x86_64
glibc-langpack-en-2.34-231.el9_7.2.x86_64
langpacks-core-font-en-3.0-16.el9.noarch
langpacks-core-en-3.0-16.el9.noarch
langpacks-en-3.0-16.el9.noarch
libstdc++-11.5.0-11.el9.x86_64
libstdc++-devel-11.5.0-11.el9.x86_64
How reproducible is this bug?:
100%
Steps to reproduce
- Create a test_case.cpp containing the following content:
```
#include <iomanip>
#include <locale>
#include <sstream>
#include <iostream>
int main(int, char**)
{
const char* month = "March";
std::tm t = {};
std::istringstream ss(month);
ss.imbue(std::locale("en_US.UTF-8"));
ss >> std::get_time(&t, "%b");
int ret = ss.fail();
if (ss.fail())
{ std::cout<<"ERROR: Parse failure"<<std::endl; }else
{ std::cout<<month << " --> t.tm_mon = " << t.tm_mon <<std::endl; }
return ret;
}
```
- Compile test_case.cpp `scl enable gcc-toolset-15 – g++ -O2 -std=c++17 -o test_case test_case.cpp`
- Or with `-O1 -fipa-sra` instead of `-O2` triggers the same behavior
- Run test_case.cpp and get return code: `./test_case ; echo $?`
Expected results
The following output is printed
```
March --> t.tm_mon = 2
0
```
Actual results
The following output is printed
```
ERROR: Parse failure
1
```
- duplicates
-
RHEL-150603 gcc-toolset-15-gcc: g++ compilation issue with -O3
-
- Planning
-