https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67555
Bug ID: 67555 Summary: Emplacement of random numbers in vector displaces other variables (loop counter) Product: gcc Version: 5.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: my.pvt.emailaddress at gmail dot com Target Milestone: --- A template function receives a lambda as parameter. This lambda creates random numbers and is used to emplace these random variables in a vector in a loop. The loop counter (int) changes suddenly after the second loop, not incrementing to 2 like expeced but to 282475250, returning after two iterations. The error does not appear when I emplace 0.0 (uncommented below). Minimal example as preprocessed file below. Preprocessed file in attachment Output of 'LANG="en_US.utf8" g++ --std=c++14 -Wall -Wextra -v -save-temps bug.cc': Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-pc-linux-gnu/5.2.0/lto-wrapper Target: i686-pc-linux-gnu Configured with: /build/gcc/src/gcc-5.2.0/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --enable-libmpx --with-system-zlib --with-isl --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object --enable-linker-build-id --enable-lto --enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu --enable-gnu-indirect-function --disable-multilib --disable-werror --enable-checking=release --with-default-libstdcxx-abi=gcc4-compatible Thread model: posix gcc version 5.2.0 (GCC) COLLECT_GCC_OPTIONS='-std=c++14' '-Wall' '-Wextra' '-v' '-save-temps' '-shared-libgcc' '-mtune=generic' '-march=pentiumpro' /usr/lib/gcc/i686-pc-linux-gnu/5.2.0/cc1plus -E -quiet -v -D_GNU_SOURCE bug.cc -mtune=generic -march=pentiumpro -std=c++14 -Wall -Wextra -fpch-preprocess -o bug.ii ignoring nonexistent directory "/usr/lib/gcc/i686-pc-linux-gnu/5.2.0/../../../../i686-pc-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /usr/lib/gcc/i686-pc-linux-gnu/5.2.0/../../../../include/c++/5.2.0 /usr/lib/gcc/i686-pc-linux-gnu/5.2.0/../../../../include/c++/5.2.0/i686-pc-linux-gnu /usr/lib/gcc/i686-pc-linux-gnu/5.2.0/../../../../include/c++/5.2.0/backward /usr/lib/gcc/i686-pc-linux-gnu/5.2.0/include /usr/local/include /usr/lib/gcc/i686-pc-linux-gnu/5.2.0/include-fixed /usr/include End of search list. COLLECT_GCC_OPTIONS='-std=c++14' '-Wall' '-Wextra' '-v' '-save-temps' '-shared-libgcc' '-mtune=generic' '-march=pentiumpro' /usr/lib/gcc/i686-pc-linux-gnu/5.2.0/cc1plus -fpreprocessed bug.ii -quiet -dumpbase bug.cc -mtune=generic -march=pentiumpro -auxbase bug -Wall -Wextra -std=c++14 -version -o bug.s GNU C++14 (GCC) version 5.2.0 (i686-pc-linux-gnu) compiled by GNU C version 5.2.0, GMP version 6.0.0, MPFR version 3.1.3-p4, MPC version 1.0.3 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 GNU C++14 (GCC) version 5.2.0 (i686-pc-linux-gnu) compiled by GNU C version 5.2.0, GMP version 6.0.0, MPFR version 3.1.3-p4, MPC version 1.0.3 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: 96ebd866b991a3692b342321700b9e9b COLLECT_GCC_OPTIONS='-std=c++14' '-Wall' '-Wextra' '-v' '-save-temps' '-shared-libgcc' '-mtune=generic' '-march=pentiumpro' as -v --32 -o bug.o bug.s GNU assembler version 2.25.1 (i686-pc-linux-gnu) using BFD version (GNU Binutils) 2.25.1 COMPILER_PATH=/usr/lib/gcc/i686-pc-linux-gnu/5.2.0/:/usr/lib/gcc/i686-pc-linux-gnu/5.2.0/:/usr/lib/gcc/i686-pc-linux-gnu/:/usr/lib/gcc/i686-pc-linux-gnu/5.2.0/:/usr/lib/gcc/i686-pc-linux-gnu/ LIBRARY_PATH=/usr/lib/gcc/i686-pc-linux-gnu/5.2.0/:/usr/lib/gcc/i686-pc-linux-gnu/5.2.0/../../../:/lib/:/usr/lib/ COLLECT_GCC_OPTIONS='-std=c++14' '-Wall' '-Wextra' '-v' '-save-temps' '-shared-libgcc' '-mtune=generic' '-march=pentiumpro' /usr/lib/gcc/i686-pc-linux-gnu/5.2.0/collect2 -plugin /usr/lib/gcc/i686-pc-linux-gnu/5.2.0/liblto_plugin.so -plugin-opt=/usr/lib/gcc/i686-pc-linux-gnu/5.2.0/lto-wrapper -plugin-opt=-fresolution=bug.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --build-id --eh-frame-hdr --hash-style=gnu -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 /usr/lib/gcc/i686-pc-linux-gnu/5.2.0/../../../crt1.o /usr/lib/gcc/i686-pc-linux-gnu/5.2.0/../../../crti.o /usr/lib/gcc/i686-pc-linux-gnu/5.2.0/crtbegin.o -L/usr/lib/gcc/i686-pc-linux-gnu/5.2.0 -L/usr/lib/gcc/i686-pc-linux-gnu/5.2.0/../../.. bug.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/i686-pc-linux-gnu/5.2.0/crtend.o /usr/lib/gcc/i686-pc-linux-gnu/5.2.0/../../../crtn.o