Bug#787217: clang++-3.7 generates wrong code with -O1 or -O2

Thibaut Paumard thibaut at debian.org
Fri May 29 20:51:37 UTC 2015

Package: clang-3.7
Version: 1:3.7~svn230892-1
Severity: important
File: /usr/bin/clang++-3.7


when I build the following code with
 clang++-3.7 -O2 -o foo foo.C
and then run ./foo, I get a SIGFPE. The example is minimal (if you remove the
cerr before, no SIGFPE). That means that the code is taking the wrong path in
the "if" clause. If you uncomment any of the two cerr within the "if", not
SIGFPE anymore.

This does not affect clang++3.4 or 3.5, it does also affect clang++-3.7 with
-O1 but not not -O0.

I haven't checked yet whether that affects upstream as well.

Kind regards, Thibaut.

foo.C -----

#include <iostream>
#include <fenv.h>

double computeCst(double QQ) {
  std::cerr << "foo\n" << std::endl;
  if (QQ==0) {
    //std::cerr << "right path\n";
    return 1.;
  } else {
    //std::cerr << "wrong path\n";
    return 1/QQ;

int main(int argc, char *argv[]) {
  return 0;

-- System Information:
Debian Release: 8.0
  APT prefers stable
  APT policy: (990, 'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.16.0-4-amd64 (SMP w/8 CPU cores)
Locale: LANG=fr_FR.utf8, LC_CTYPE=fr_FR.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages clang-3.7 depends on:
ii  binutils                 2.25-5
ii  libc6                    2.19-18
ii  libc6-dev                2.19-18
ii  libclang-common-3.7-dev  1:3.7~svn230892-1
ii  libclang1-3.7            1:3.7~svn230892-1
ii  libedit2                 3.1-20140620-2
ii  libffi6                  3.1-2+b2
ii  libgcc-4.9-dev           4.9.2-10
ii  libgcc1                  1:4.9.2-10
ii  libllvm3.7               1:3.7~svn230892-1
ii  libobjc-4.9-dev          4.9.2-10
ii  libstdc++-4.9-dev        4.9.2-10
ii  libstdc++6               4.9.2-10
ii  libtinfo5                5.9+20140913-1+b1
ii  zlib1g                   1:1.2.8.dfsg-2+b1

Versions of packages clang-3.7 recommends:
pn  llvm-3.7-dev  <none>
ii  python        2.7.9-1

Versions of packages clang-3.7 suggests:
pn  clang-3.7-doc  <none>
pn  gnustep        <none>
pn  gnustep-devel  <none>

-- no debconf information

More information about the Pkg-llvm-team mailing list