https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77669

            Bug ID: 77669
           Summary: Incorrect LTO code on embedded ARM
           Product: gcc
           Version: 5.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: lto
          Assignee: unassigned at gcc dot gnu.org
          Reporter: wgh at beyondunreal dot com
  Target Milestone: ---

So I've been playing around with my STM32 microcontroller and various compiler
options, and noticed that my program doesn't work when I build it with LTO.

I've observed this behaviour on GCC 4.9.3 and 5.4.0.

The problematic piece of code looks like this:
    auto i = std::uniform_int_distribution<>(0, ncolors - 1)(random_engine);

Where random_engine is declared at global level
    static std::minstd_rand random_engine;

The function simply never returns.

According to my debugging, the generator returns always zero, and it causes the
"downscale" loop inside uniform_int_distribution::operator()
(/usr/lib/gcc/armv7m-hardfloat-eabi/5.4.0/include/g++-v5/bits/uniform_int_dist.h)
to loop forever.

I'll try to post some more debugging info soon.

Using built-in specs.
COLLECT_GCC=/usr/x86_64-pc-linux-gnu/armv7m-hardfloat-eabi/gcc-bin/5.4.0/armv7m-hardfloat-eabi-g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/armv7m-hardfloat-eabi/5.4.0/lto-wrapper
Target: armv7m-hardfloat-eabi
Configured with:
/var/tmp/portage/cross-armv7m-hardfloat-eabi/gcc-5.4.0/work/gcc-5.4.0/configure
--host=x86_64-pc-linux-gnu --target=armv7m-hardfloat-eabi
--build=x86_64-pc-linux-gnu --prefix=/usr
--bindir=/usr/x86_64-pc-linux-gnu/armv7m-hardfloat-eabi/gcc-bin/5.4.0
--includedir=/usr/lib/gcc/armv7m-hardfloat-eabi/5.4.0/include
--datadir=/usr/share/gcc-data/armv7m-hardfloat-eabi/5.4.0
--mandir=/usr/share/gcc-data/armv7m-hardfloat-eabi/5.4.0/man
--infodir=/usr/share/gcc-data/armv7m-hardfloat-eabi/5.4.0/info
--with-gxx-include-dir=/usr/lib/gcc/armv7m-hardfloat-eabi/5.4.0/include/g++-v5
--with-python-dir=/share/gcc-data/armv7m-hardfloat-eabi/5.4.0/python
--enable-languages=c,c++ --enable-obsolete --enable-secureplt --disable-werror
--with-system-zlib --enable-nls --without-included-gettext
--enable-checking=release --with-bugurl=https://bugs.gentoo.org/
--with-pkgversion='Gentoo 5.4.0 p1.0, pie-0.6.5' --enable-libstdcxx-time
--enable-poison-system-directories --with-sysroot=/usr/armv7m-hardfloat-eabi
--disable-bootstrap --with-newlib --enable-multilib --disable-altivec
--disable-fixed-point --with-float=hard --with-arch=armv7-m --with-mode=thumb
--with-float=hard --with-fpu=vfpv3-d16 --disable-libgcj --disable-libgomp
--disable-libmudflap --disable-libssp --disable-libcilkrts --disable-libmpx
--enable-vtable-verify --enable-libvtv --disable-libquadmath --enable-lto
--without-isl --disable-libsanitizer
Thread model: single
gcc version 5.4.0 (Gentoo 5.4.0 p1.0, pie-0.6.5)

Reply via email to