Undefined Behavior in GCC 4.8 ios_base.h
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
gcc |
Fix Released
|
Medium
|
|||
gcc-4.8 (Ubuntu) |
Fix Released
|
Medium
|
Unassigned | ||
Trusty |
Fix Released
|
Medium
|
Unassigned | ||
gcc-5 (Debian) |
Fix Released
|
Unknown
|
|||
gcc-5 (Ubuntu) |
Fix Released
|
Medium
|
Unassigned |
Bug Description
On Linux, the distros often use libstdc++ rather than libc++ for Clang. Building libcxx is an art that I have never been able to untangle, and I think the maintainers have discovered the same.
Below, I'm catching a UB finding when using Clang and libstdc++. This one has been around for some time. I first encountered it on Apple platforms. I regularly encounter it on Debian and Ubuntu.
The fix is fairly easy, and I usually just do it: a couple of casts among unsigned and the flags. Also see http://
**********
$ cat ub.cxx
#include <iostream>
int main(int argc, char* argv[])
{
std::cout << std::hex << argc << std::endl;
std::cout << std::dec << argc << std::endl;
return 0;
}
$ clang++ -fsanitize=
$ ./ub.exe
/usr/lib/
/usr/lib/
1
1
**********
$ g++ --version
g++ (Ubuntu 4.8.4-2ubuntu1~
$ uname -a
Linux ubuntu 3.13.0-66-generic #108-Ubuntu SMP Wed Oct 7 15:20:27 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
$ lsb_release
No LSB modules are available.
**********
$ apt-cache show g++
Package: g++
Priority: optional
Section: devel
Installed-Size: 34
Maintainer: Ubuntu Developers <email address hidden>
Original-
Architecture: amd64
Source: gcc-defaults (1.124ubuntu6)
Version: 4:4.8.2-1ubuntu6
Provides: c++-compiler
Depends: cpp (>= 4:4.8.2-1ubuntu6), gcc (>= 4:4.8.2-1ubuntu6), g++-4.8 (>= 4.8.2-5~), gcc-4.8 (>= 4.8.2-5~)
Suggests: g++-multilib
Filename: pool/main/
Size: 1490
MD5sum: 7332a4e9116b821
SHA1: 2c7201808be1029
SHA256: 02c3d204efe6c34
Description-en: GNU C++ compiler
This is the GNU C++ compiler, a fairly portable optimizing compiler for C++.
.
This is a dependency package providing the default GNU C++ compiler.
Description-md5: 4d44b18774ae512
Bugs: https:/
Build-Essential: yes
Origin: Ubuntu
Supported: 5y
affects: | gcc-defaults (Ubuntu) → gcc-4.8 (Ubuntu) |
Changed in gcc-4.8 (Ubuntu): | |
status: | New → Confirmed |
Changed in gcc-4.8 (Ubuntu): | |
importance: | Undecided → Medium |
Changed in gcc-4.8 (Ubuntu Trusty): | |
importance: | Undecided → Medium |
Changed in gcc-5 (Debian): | |
status: | Unknown → Fix Released |
Changed in gcc: | |
importance: | Unknown → Medium |
status: | Unknown → Fix Released |
This bug was fixed in the package gcc-4.8 - 4.8.5-2ubuntu1
---------------
gcc-4.8 (4.8.5-2ubuntu1) xenial; urgency=medium
* Merge with Debian; remaining changes:
- Build from the upstream source.
gcc-4.8 (4.8.5-2) unstable; urgency=medium
* Update the Linaro support to the 4.8-2015.07 release.
* Adjust setting DH_COMPAT for dh_movefiles with updated debhelper supporting
globbing of arguments. Closes: #800248.
* Fix PR libstdc++/56158, taken from the trunk.
Addresses: #804521. LP: #1514309.
* Backport fixes to allow building with cloog-0.18.4 and isl-0.15.
* Backport PR target/67281 from the trunk (HTM fixes). LP: #1517093.
* Fix auto-loading of gdb pretty printers. LP: #1446828.
-- Matthias Klose <email address hidden> Wed, 18 Nov 2015 19:57:42 +0100