[Bug sanitizer/57507] New: gcc 4.8: thread sanitizer: std::thread false(?) positive
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57507 Bug ID: 57507 Summary: gcc 4.8: thread sanitizer: std::thread false(?) positive Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: sanitizer Assignee: unassigned at gcc dot gnu.org Reporter: alxchk at alxchk dot me CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org, jakub at gcc dot gnu.org, kcc at gcc dot gnu.org $ cat test.cpp #include int main(int argc, char *argv[]) { std::thread t([](){}); t.join(); return 0; } $ LC_ALL=C g++ --version g++ (Gentoo Hardened 4.8.0 p1.2, pie-0.5.5) 4.8.0 Copyright (C) 2013 Free Software Foundation, Inc. $ g++ -o test test.cpp --std=gnu++11 -pthread -fsanitize=thread -ggdb3 -O0 $ ./test == WARNING: ThreadSanitizer: data race (pid=14129) Write of size 8 at 0x7d08bfc8 by thread T1: #0 :0 (libtsan.so.0+0x00020dc0) #1 deallocate /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/include/g++-v4/ext/new_allocator.h:110 (exe+0x2b42) #2 deallocate /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/include/g++-v4/bits/alloc_traits.h:377 (exe+0x2972) #3 _M_destroy /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/include/g++-v4/bits/shared_ptr_base.h:417 (exe+0x3336) #4 :0 (libstdc++.so.6+0x000c8cea) Previous atomic write of size 4 at 0x7d08bfc8 by main thread: #0 :0 (libtsan.so.0+0xdfc5) #1 __exchange_and_add /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/include/g++-v4/ext/atomicity.h:47 (exe+0x1898) #2 __exchange_and_add_dispatch /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/include/g++-v4/ext/atomicity.h:80 (exe+0x1995) #3 std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/include/g++-v4/bits/shared_ptr_base.h:141 (exe+0x3c86) #4 std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count() /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/include/g++-v4/bits/shared_ptr_base.h:553 (exe+0x3c2d) #5 std::__shared_ptr::~__shared_ptr() /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/include/g++-v4/bits/shared_ptr_base.h:810 (exe+0x3aae) #6 std::shared_ptr::~shared_ptr() /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/include/g++-v4/bits/shared_ptr.h:93 (exe+0x3afc) #7 thread /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/include/g++-v4/thread:135 (exe+0x1c10) #8 main /tmp/test.cpp:5 (exe+0x1a3e) Location is heap block of size 56 at 0x7d08bfc0 allocated by main thread: #0 :0 (libtsan.so.0+0x00020ad2) #1 allocate /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/include/g++-v4/ext/new_allocator.h:104 (exe+0x2a5b) #2 allocate /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/include/g++-v4/bits/alloc_traits.h:351 (exe+0x2881) #3 __shared_count >, std::allocator > >, std::_Bind_simple > /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/include/g++-v4/bits/shared_ptr_base.h:519 (exe+0x26e5) #4 __shared_ptr > >, std::_Bind_simple > /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/include/g++-v4/bits/shared_ptr_base.h:986 (exe+0x25a1) #5 shared_ptr > >, std::_Bind_simple > /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/include/g++-v4/bits/shared_ptr.h:316 (exe+0x2511) #6 allocate_shared >, std::allocator > >, std::_Bind_simple > /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/include/g++-v4/bits/shared_ptr.h:598 (exe+0x2422) #7 make_shared >, std::_Bind_simple > /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/include/g++-v4/bits/shared_ptr.h:614 (exe+0x225a) #8 _M_make_routine > /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/include/g++-v4/thread:193 (exe+0x1fa2) #9 thread /usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/include/g++-v4/thread:135 (exe+0x1bde) #10 main /tmp/test.cpp:5 (exe+0x1a3e) Thread T1 (tid=14130, running) created by main thread at: #0 :0 (libtsan.so.0+0x00022cdb) #1 :0 (libstdc++.so.6+0x000c8ef6) #2 main /tmp/test.cpp:5 (exe+0x1a3e) SUMMARY: ThreadSanitizer: data race ??:0 ?? == ThreadSanitizer: reported 1 warnings
[Bug c++/57437] New: C++11: mutable lambdas; gcc 4.7-4.8
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57437 Bug ID: 57437 Summary: C++11: mutable lambdas; gcc 4.7-4.8 Product: gcc Version: 4.7.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: alxchk at alxchk dot me > cat test.cpp #include #include int main(int argc, char *argv[]) { auto x = std::vector({1, 2, 3}); auto y = [x] () mutable { for (auto &i: x) i ++; return x; }; for (const auto &i: y()) std::cout << i << std::endl; for (const auto &i: y()) std::cout << i << std::endl; return 0; } > x86_64-pc-linux-gnu-g++-4.6.3 -o test test.cpp -std=gnu++0x > ./test 2 3 4 3 4 5 > LC_ALL=C x86_64-pc-linux-gnu-g++-4.6.3 -v Using built-in specs. COLLECT_GCC=x86_64-pc-linux-gnu-g++-4.6.3 COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/4.6.3/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /var/tmp/portage/portage/sys-devel/gcc-4.6.3/work/gcc-4.6.3/configure --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.6.3 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.6.3 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.6.3/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.6.3/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/include/g++-v4 --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec --disable-fixed-point --with-ppl --with-cloog --disable-ppl-version-check --with-cloog-include=/usr/include/cloog-ppl --enable-lto --enable-nls --without-included-gettext --with-system-zlib --enable-obsolete --disable-werror --enable-secureplt --enable-multilib --enable-libmudflap --disable-libssp --enable-esp --enable-libgomp --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/4.6.3/python --enable-checking=release --disable-libgcj --enable-libstdcxx-time --enable-languages=c,c++,objc,fortran --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-targets=all --with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo Hardened 4.6.3 p1.11, pie-0.5.2' Thread model: posix gcc version 4.6.3 (Gentoo Hardened 4.6.3 p1.11, pie-0.5.2) > x86_64-pc-linux-gnu-g++-4.7.2 -o test2 test.cpp -std=gnu++0x > ./test2 2 3 4 > LC_ALL=C x86_64-pc-linux-gnu-g++-4.7.2 -v Using built-in specs. COLLECT_GCC=x86_64-pc-linux-gnu-g++-4.7.2 COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/4.7.2/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /var/tmp/portage/portage/sys-devel/gcc-4.7.2-r1/work/gcc-4.7.2/configure --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.7.2 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.2/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.7.2 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.7.2/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.7.2/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.2/include/g++-v4 --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec --disable-fixed-point --with-ppl --with-cloog --disable-ppl-version-check --with-cloog-include=/usr/include/cloog-ppl --enable-lto --enable-nls --without-included-gettext --with-system-zlib --enable-obsolete --disable-werror --enable-secureplt --enable-multilib --with-multilib-list=m32,m64 --enable-libmudflap --disable-libssp --enable-esp --enable-libgomp --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/4.7.2/python --enable-checking=release --disable-libgcj --enable-libstdcxx-time --enable-languages=c,c++,objc,fortran --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-targets=all --with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo Hardened 4.7.2-r1 p1.5, pie-0.5.5' Thread model: posix gcc version 4.7.2 (Gentoo Hardened 4.7.2-r1 p1.5, pie-0.5.5) > x86_64-pc-linux-gnu-g++-4.8.0 -o test test.cpp -std=gnu++11 > ./test 2 3 4 > LC_ALL=C x86_64-pc-linux-gnu-g++-4.8.0 -v Using built-in specs. COLLECT_GCC=x86_64-pc-linux-gnu-g++-4.8.0 COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/4.8.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /tmp/portage/sys-devel/gcc-4.8.0/work/gcc-4.8.0/configure --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.8.0 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.8.0 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.8.0/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.8.0/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.0/include/g++-v4 --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec --disable-fixed-point --with-ppl --with-cloog --disable-isl-version-check --with-cloog --enable-lto --enable-nls --w