[Bug c++/96117] New: Cannot mix c++11-style and GCC-style attributes
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96117 Bug ID: 96117 Summary: Cannot mix c++11-style and GCC-style attributes Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: steveire at gmail dot com Target Milestone: --- ``` struct __attribute__((visibility("default"))) [[deprecated("a message")]] A1 { }; struct __attribute__((__deprecated__("a message"))) __attribute__((visibility("default"))) A2 { }; ``` A EXPORT macro containing a GCC-style visibility attribute (generated by CMake) and another macro containing a c++11-style macro can not be used to decorate a class. https://godbolt.org/z/qHxr6s
[Bug c++/92914] New: Hidden visibility incompatible with extern'd specialized explicit template instantiations
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92914 Bug ID: 92914 Summary: Hidden visibility incompatible with extern'd specialized explicit template instantiations Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: steveire at gmail dot com Target Milestone: --- I'm trying to use hidden visibility with a library which is already used with MSVC. It uses exported explicit template specializations. mylib.h:- #pragma once #if _MSC_VER # ifdef mylib_EXPORTS #define MYLIB_EXPORT __declspec(dllexport) # else #define MYLIB_EXPORT __declspec(dllimport) # endif #else # ifdef mylib_EXPORTS #define MYLIB_EXPORT __attribute__((visibility("default"))) # else #define MYLIB_EXPORT # endif #endif template class Templ { public: T getNum() const; T getAnotherNum() const; }; #ifdef SPECIALIZE_INT template<> MYLIB_EXPORT int Templ::getNum() const; #endif #ifndef mylib_EXPORTS extern template class Templ; extern template class Templ; #endif - mylib.cpp- #include "mylib.h" template T Templ::getNum() const { return 7; } template T Templ::getAnotherNum() const { return 5; } #ifdef SPECIALIZE_INT template<> int Templ::getNum() const { return 42; } #endif template class MYLIB_EXPORT Templ; template class MYLIB_EXPORT Templ; - main.cpp-- #include "mylib.h" #include int main() { Templ ti; Templ tf; std::cout << ti.getNum() << " -- " << ti.getAnotherNum() << tf.getNum() << " -- " << tf.getAnotherNum() << std::endl; return 0; } - build.sh-- #!/bin/sh set -x COMPILE_DRIVER=g++ COMPILE_DRIVER=clang++ $COMPILE_DRIVER -Dmylib_EXPORTS -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -o mylib.$COMPILE_DRIVER.o -c ../mylib.cpp $COMPILE_DRIVER -fPIC -Wl,--no-undefined -shared -o libmylib.so mylib.$COMPILE_DRIVER.o $COMPILE_DRIVER -fvisibility=hidden -fvisibility-inlines-hidden -o main.$COMPILE_DRIVER.o -c ../main.cpp $COMPILE_DRIVER main.$COMPILE_DRIVER.o -o myexe -Wl,-rpath,$PWD libmylib.so # Compile with SPECIALIZE_INT defined: $COMPILE_DRIVER -DSPECIALIZE_INT -Dmylib_EXPORTS -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -o mylib.$COMPILE_DRIVER.o -c ../mylib.cpp $COMPILE_DRIVER -fPIC -Wl,--no-undefined -shared -o libmylib.so mylib.$COMPILE_DRIVER.o $COMPILE_DRIVER -DSPECIALIZE_INT -fvisibility=hidden -fvisibility-inlines-hidden -o main.$COMPILE_DRIVER.o -c ../main.cpp $COMPILE_DRIVER main.$COMPILE_DRIVER.o -o myexe -Wl,-rpath,$PWD libmylib.so --- clang --- + clang++ -Dmylib_EXPORTS -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -o mylib.clang++.o -c ../mylib.cpp + clang++ -fPIC -Wl,--no-undefined -shared -o libmylib.so mylib.clang++.o + clang++ -fvisibility=hidden -fvisibility-inlines-hidden -o main.clang++.o -c ../main.cpp + clang++ main.clang++.o -o myexe -Wl,-rpath,/home/stephen/dev/src/playground/cpp/build libmylib.so + clang++ -DSPECIALIZE_INT -Dmylib_EXPORTS -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -o mylib.clang++.o -c ../mylib.cpp + clang++ -fPIC -Wl,--no-undefined -shared -o libmylib.so mylib.clang++.o + clang++ -DSPECIALIZE_INT -fvisibility=hidden -fvisibility-inlines-hidden -o main.clang++.o -c ../main.cpp + clang++ main.clang++.o -o myexe -Wl,-rpath,/home/stephen/dev/src/playground/cpp/build libmylib.so --- While this works with clang above, it does not work with GCC: gcc --- + g++ -Dmylib_EXPORTS -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -o mylib.g++.o -c ../mylib.cpp + g++ -fPIC -Wl,--no-undefined -shared -o libmylib.so mylib.g++.o + g++ -fvisibility=hidden -fvisibility-inlines-hidden -o main.g++.o -c ../main.cpp + g++ main.g++.o -o myexe -Wl,-rpath,/home/stephen/dev/src/playground/cpp/build libmylib.so + g++ -DSPECIALIZE_INT -Dmylib_EXPORTS -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -o mylib.g++.o -c ../mylib.cpp ../mylib.cpp:24:29: warning: type attributes ignored after type is already defined [-Wattributes] template class MYLIB_EXPORT Templ; ^~ + g++ -fPIC -Wl,--no-undefined -shared -o libmylib.so mylib.g++.o + g++ -DSPECIALIZE_INT -fvisibility=hidden -fvisibility-inlines-hidden -o main.g++.o -c ../main.cpp + g++ main.g++.o -o myexe -Wl,-rpath,/home/stephen/dev/src/playground/cpp/build libmylib.so main.g++.o: In function `main': main.cpp:(.text+0x4c): undefined reference to `Templ::getAnotherNum() const' collect2: error: ld returned 1 exit status ---
[Bug c++/92914] Hidden visibility incompatible with extern'd specialized explicit template instantiations
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92914 --- Comment #1 from Stephen --- www.open-std.org/jtc1/sc22AC/wg21/docs/papers/2017/p0537r0.html may be related to this too.
[Bug c++/92914] Hidden visibility incompatible with extern'd specialized explicit template instantiations
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92914 --- Comment #2 from Stephen --- Also: stephen@j5:~/dev/src/playground/cpp/build$ nm mylib.g++.o | c++filt W Templ::getAnotherNum() const W Templ::getNum() const W Templ::getAnotherNum() const T Templ::getNum() const stephen@j5:~/dev/src/playground/cpp/build$ nm mylib.clang++.o | c++filt r .LCPI2_0 0004 r .LCPI3_0 W Templ::getAnotherNum() const W Templ::getNum() const W Templ::getAnotherNum() const T Templ::getNum() const
[Bug c++/92914] Hidden visibility incompatible with extern'd specialized explicit template instantiations
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92914 --- Comment #3 from Stephen --- Also, I tried to follow what I think was indicated in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56328 in that I forward declared the specialization in the header.
[Bug c++/92914] Hidden visibility incompatible with extern'd specialized explicit template instantiations
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92914 --- Comment #4 from Stephen --- https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55347 is also related.
[Bug c++/55183] New: GCC 4.8 constexpr is too permissive
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55183 Bug #: 55183 Summary: GCC 4.8 constexpr is too permissive Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: steve...@gmail.com In the second patch set here uploaded by my colleague: https://codereview.qt-project.org/#change,33290 GCC 4.8 was too permissive in its handling of constexpr compared to GCC 4.6 and clang. I don't know how to create a minimal testcase for this issue, but wanted to file it in case it can be fixed before 4.8 is released.
[Bug c++/55183] GCC 4.8 constexpr is too permissive
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55183 --- Comment #5 from Stephen 2012-11-03 10:48:02 UTC --- Thanks for the information. The issue is indeed about use of reinterpret_cast in a constexpr method. The consensus, according to bug 55039, is that this should not be supported. There is also a lot of mention of 'the other PR'. Am I missing something, or is GCC being non-strict by still supporting this? Is there a stricter mode where this and other extensions are not available (for writing portable code)?
[Bug c++/54086] New: GCC should allow constexpr and const together
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54086 Bug #: 54086 Summary: GCC should allow constexpr and const together Classification: Unclassified Product: gcc Version: 4.6.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: steve...@gmail.com GCC and Clang differ in how they handle this code. Clang compiles it, but GCC does not: #include static constexpr const char Data[] = { 'D', 'A', 'T', 'A', }; static constexpr const char *data_func() { return Data; } int main(int argc, char **argv) { char c = 'T'; switch(c) { case *data_func(): std::cout << "GOT A D" << std::endl; break; case *(data_func() + 2): std::cout << "GOT A T" << std::endl; } } $ clang++ --version clang version 3.2 Target: x86_64-unknown-linux-gnu Thread model: posix $ g++ -dumpversion 4.6.1 $ g++ main.cpp -std=c++0x main.cpp:163:48: error: both ‘const’ and ‘constexpr’ cannot be used here http://thread.gmane.org/gmane.comp.compilers.clang.devel/22984 Thanks,
[Bug c++/56071] New: noexcept with template and private ctor fails
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56071 Bug #: 56071 Summary: noexcept with template and private ctor fails Classification: Unclassified Product: gcc Version: 4.7.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: steve...@gmail.com $ g++ --version g++ (Ubuntu/Linaro 4.7.2-2ubuntu1) 4.7.2 The following code is accepted by clang++, but not g++: class B { template friend struct A; private: B() {} ~B() {} }; template struct A { T t; B b; A() noexcept(noexcept(B())) {} }; #define BREAK struct C { A delegate; C() #ifdef BREAK noexcept(noexcept(A())) #endif { } }; int main() {return 0;} If the #define BREAK is commented out, it is accepted by g++ too. Making A not a template type also makes g++ accept it.
[Bug c++/56071] friend class template cannot access private constructor in exception-specification
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56071 --- Comment #2 from Stephen 2013-01-22 01:44:19 UTC --- Interestingly, add variadic templates to the mix and it compiles: class B { template friend struct A; private: B(int, char) {} ~B() {} }; template struct A { T t; template A(Args&&... args) noexcept(noexcept(T(std::forward(args)...))) : t(std::forward(args)...) {} }; struct C { A delegate; template C(Args&&... args) noexcept(noexcept(A(std::forward(args)...))) : delegate(std::forward(args)...) { } };
[Bug c++/56071] friend class template cannot access private constructor in exception-specification
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56071 --- Comment #3 from Stephen 2013-01-22 08:41:02 UTC --- clang has other issues relating to this. Something to maybe add unit tests for if they don't exist already: http://thread.gmane.org/gmane.comp.compilers.clang.devel/27226
[Bug c++/56071] friend class template cannot access private constructor in exception-specification
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56071 --- Comment #7 from Stephen 2013-01-22 17:28:14 UTC --- Thank you!
[Bug c++/70636] New: Link failure when C++ brace initialization is used
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70636 Bug ID: 70636 Summary: Link failure when C++ brace initialization is used Product: gcc Version: 5.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: steveire at gmail dot com Target Milestone: --- $ g++ --version g++ (Ubuntu 5.2.1-22ubuntu2) 5.2.1 20151010 Copyright (C) 2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ cat brace-init.cpp #include #include class Expression { public: std::vector args; }; Expression getExpr(const Expression& def = {}) { return def; } int main() { auto a = getExpr(); // auto a = getExpr({}); } $ g++ brace-init.cpp -std=c++11 -v Using built-in specs. COLLECT_GCC=/usr/bin/g++ COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.2.1-22ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu Thread model: posix gcc version 5.2.1 20151010 (Ubuntu 5.2.1-22ubuntu2) COLLECT_GCC_OPTIONS='-std=c++11' '-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64' /usr/lib/gcc/x86_64-linux-gnu/5/cc1plus -quiet -v -imultiarch x86_64-linux-gnu -D_GNU_SOURCE brace-init.cpp -quiet -dumpbase brace-init.cpp -mtune=generic -march=x86-64 -auxbase brace-init -std=c++11 -version -fstack-protector-strong -Wformat -Wformat-security -o /tmp/ccsM0fgs.s GNU C++11 (Ubuntu 5.2.1-22ubuntu2) version 5.2.1 20151010 (x86_64-linux-gnu) compiled by GNU C version 5.2.1 20151010, GMP version 6.0.0, MPFR version 3.1.3, MPC version 1.0.3 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/5" ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu" ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/5/../../../../x86_64-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /usr/include/c++/5 /usr/include/x86_64-linux-gnu/c++/5 /usr/include/c++/5/backward /usr/lib/gcc/x86_64-linux-gnu/5/include /usr/local/include /usr/lib/gcc/x86_64-linux-gnu/5/include-fixed /usr/include/x86_64-linux-gnu /usr/include End of search list. GNU C++11 (Ubuntu 5.2.1-22ubuntu2) version 5.2.1 20151010 (x86_64-linux-gnu) compiled by GNU C version 5.2.1 20151010, GMP version 6.0.0, MPFR version 3.1.3, MPC version 1.0.3 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: 5ed623d6fe11f4bcc1afee70f77e33b0 COLLECT_GCC_OPTIONS='-std=c++11' '-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64' as -v --64 -o /tmp/cc7GSdPa.o /tmp/ccsM0fgs.s GNU assembler version 2.25.1 (x86_64-linux-gnu) using BFD version (GNU Binutils for Ubuntu) 2.25.1 COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/ LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/5/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/5/../../../:/lib/:/usr/lib/ COLLECT_GCC_OPTIONS='-std=c++11' '-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64' /usr/lib/gcc/x86_64-linux-gnu/5/collect2 -plugin /usr/lib/gcc/x86_64-linux-gnu/5/liblto_plugin.so -plugin-opt=/usr/lib/gcc/x
[Bug c++/70637] New: Ambiguity error invoking a constructor with double brace initialization
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70637 Bug ID: 70637 Summary: Ambiguity error invoking a constructor with double brace initialization Product: gcc Version: 5.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: steveire at gmail dot com Target Milestone: --- $ g++ --version g++ (Ubuntu 5.2.1-22ubuntu2) 5.2.1 20151010 Copyright (C) 2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ g++ double-braces.cpp -std=c++11 double-braces.cpp: In function ‘int main()’: double-braces.cpp:16:20: error: call of overloaded ‘SomeClass()’ is ambiguous SomeClass sc({{}}); ^ double-braces.cpp:7:12: note: candidate: SomeClass::SomeClass(std::vector >) explicit SomeClass(std::vector> samples) ^ double-braces.cpp:4:7: note: candidate: SomeClass::SomeClass(const SomeClass&) class SomeClass ^ double-braces.cpp:4:7: note: candidate: SomeClass::SomeClass(SomeClass&&) $ cat double-braces.cpp #include class SomeClass { public: explicit SomeClass(std::vector> samples) : mSamples(std::move(samples)) { } std::vector> mSamples; }; int main() { SomeClass sc({{}}); }
[Bug libstdc++/65085] New: Move-assigned empty string corrupt with -D_GLIBCXX_USE_CXX11_ABI=1
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65085 Bug ID: 65085 Summary: Move-assigned empty string corrupt with -D_GLIBCXX_USE_CXX11_ABI=1 Product: gcc Version: 5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: steveire at gmail dot com GCC 5.0 generates corrupt CMake binaries currently: http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/12392/focus=12420 The cause seems to be between the new ABI and moving an empty std::string: stephen@hal:~/dev/src/playground/cpp{master}$ /home/stephen/dev/prefix/bin/g++-5.0 -v -std=gnu++11 membug.cpp -D_GLIBCXX_USE_CXX11_ABI=1 -g Using built-in specs. COLLECT_GCC=/home/stephen/dev/prefix/bin/g++-5.0 COLLECT_LTO_WRAPPER=/home/stephen/dev/prefix/libexec/gcc/x86_64-unknown-linux-gnu/5.0.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../../../src/gcc/configure --prefix=/home/stephen/dev/prefix --enable-languages=c,c++ --program-suffix=-5.0 --enable-checking=release --with-system-zlib Thread model: posix gcc version 5.0.0 20150130 (experimental) (GCC) COLLECT_GCC_OPTIONS='-v' '-std=gnu++11' '-D' '_GLIBCXX_USE_CXX11_ABI=1' '-g' '-shared-libgcc' '-mtune=generic' '-march=x86-64' /home/stephen/dev/prefix/libexec/gcc/x86_64-unknown-linux-gnu/5.0.0/cc1plus -quiet -v -imultiarch x86_64-linux-gnu -D_GNU_SOURCE -D _GLIBCXX_USE_CXX11_ABI=1 membug.cpp -quiet -dumpbase membug.cpp -mtune=generic -march=x86-64 -auxbase membug -g -std=gnu++11 -version -o /tmp/ccruY1vz.s GNU C++11 (GCC) version 5.0.0 20150130 (experimental) (x86_64-unknown-linux-gnu) compiled by GNU C version 5.0.0 20150130 (experimental), GMP version 6.0.0, MPFR version 3.1.2-p3, MPC version 1.0.2 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu" ignoring nonexistent directory "/home/stephen/dev/prefix/lib/gcc/x86_64-unknown-linux-gnu/5.0.0/../../../../x86_64-unknown-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /home/stephen/dev/prefix/lib/gcc/x86_64-unknown-linux-gnu/5.0.0/../../include/c++/5.0.0 /home/stephen/dev/prefix/lib/gcc/x86_64-unknown-linux-gnu/5.0.0/../../include/c++/5.0.0/x86_64-unknown-linux-gnu /home/stephen/dev/prefix/lib/gcc/x86_64-unknown-linux-gnu/5.0.0/../../include/c++/5.0.0/backward /home/stephen/dev/prefix/lib/gcc/x86_64-unknown-linux-gnu/5.0.0/include /usr/local/include /home/stephen/dev/prefix/include /home/stephen/dev/prefix/lib/gcc/x86_64-unknown-linux-gnu/5.0.0/include-fixed /usr/include/x86_64-linux-gnu /usr/include End of search list. GNU C++11 (GCC) version 5.0.0 20150130 (experimental) (x86_64-unknown-linux-gnu) compiled by GNU C version 5.0.0 20150130 (experimental), GMP version 6.0.0, MPFR version 3.1.2-p3, MPC version 1.0.2 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: 017a5c35f0da909f1ce909a8ebb21479 COLLECT_GCC_OPTIONS='-v' '-std=gnu++11' '-D' '_GLIBCXX_USE_CXX11_ABI=1' '-g' '-shared-libgcc' '-mtune=generic' '-march=x86-64' as -v --64 -o /tmp/ccA64A8Z.o /tmp/ccruY1vz.s GNU assembler version 2.24.51 (x86_64-linux-gnu) using BFD version (GNU Binutils for Ubuntu) 2.24.90.20141014 COMPILER_PATH=/home/stephen/dev/prefix/libexec/gcc/x86_64-unknown-linux-gnu/5.0.0/:/home/stephen/dev/prefix/libexec/gcc/x86_64-unknown-linux-gnu/5.0.0/:/home/stephen/dev/prefix/libexec/gcc/x86_64-unknown-linux-gnu/:/home/stephen/dev/prefix/lib/gcc/x86_64-unknown-linux-gnu/5.0.0/:/home/stephen/dev/prefix/lib/gcc/x86_64-unknown-linux-gnu/ LIBRARY_PATH=/home/stephen/dev/prefix/lib/gcc/x86_64-unknown-linux-gnu/5.0.0/:/home/stephen/dev/prefix/lib/gcc/x86_64-unknown-linux-gnu/5.0.0/../../../x86_64-linux-gnu/:/home/stephen/dev/prefix/lib/gcc/x86_64-unknown-linux-gnu/5.0.0/../../../../lib64/:/lib/x86_64-linux-gnu/:/lib/../lib64/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib64/:/home/stephen/dev/prefix/lib/gcc/x86_64-unknown-linux-gnu/5.0.0/../../../:/lib/:/usr/lib/ COLLECT_GCC_OPTIONS='-v' '-std=gnu++11' '-D' '_GLIBCXX_USE_CXX11_ABI=1' '-g' '-shared-libgcc' '-mtune=generic' '-march=x86-64' /home/stephen/dev/prefix/libexec/gcc/x86_64-unknown-linux-gnu/5.0.0/collect2 -plugin /home/stephen/dev/prefix/libexec/gcc/x86_64-unknown-linux-gnu/5.0.0/liblto_plugin.so -plugin-opt=/home/stephen/dev/prefix/libexec/gcc/x86_64-unknown-linux-gnu/5.0.0/lto-wrapper -plugin-opt=-fresolution=/tmp/cckIzEMq.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-thro
[Bug c++/108385] New: false positive -Wfree-nonheap-object
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108385 Bug ID: 108385 Summary: false positive -Wfree-nonheap-object Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: steveire at gmail dot com Target Milestone: --- Sorry I was not able to reduce this further. Changing almost anything makes the bug no-longer reproduce: ``` #include #include #include class DataType { public: DataType() { } DataType get() const; private: double v = 0.0; char values[41]; }; class ptrType { public: DataType someMethod() const { DataType t; t = t.get(); return t; } }; class AnotherDataType { public: typedef uint32_t size_type; AnotherDataType() : _size(0), _data(new double[0]) {} explicit AnotherDataType(size_type size) : _size(size), _data(new double[size]) {} virtual ~AnotherDataType() { delete[] _data; } uint32_t size() const { return _size; } double& operator()(size_type i) { return _data[i]; } AnotherDataType get(const AnotherDataType& b) const { AnotherDataType c(size()); auto aItr = _data; auto cItr = c.begin(); auto endp = _data + _size; for (; aItr != endp; ++aItr, ++cItr) { (*cItr) = (*aItr); } return c; } double sum() const { double sum = *_data; auto aItr = _data; for (; aItr != _data + _size; ++aItr) { sum = (*aItr); } return sum; } double* begin() { return _data; } private: size_type _size; double* _data; }; AnotherDataType anotherMethod(const ptrType* ptrType1) { ptrType1->someMethod(); return {}; } struct otherStruct { const ptrType* ptrType1; std::vector q1; }; static double minF(otherStruct* params) { auto err = anotherMethod(params->ptrType1); return (err.get(err)).sum(); } struct someStruct { double (*f)(otherStruct* params); otherStruct* params; }; void foo(someStruct function) { std::vector v; minF(function.params); } void why() { someStruct func; func.f = &minF; foo(func); } ``` Godbolt link: https://godbolt.org/z/nqvsezj49
[Bug c++/108416] New: False positive -Wdangling-pointer
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108416 Bug ID: 108416 Summary: False positive -Wdangling-pointer Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: steveire at gmail dot com Target Milestone: --- ``` #include class HoldsNonOwning { public: void reset(int* nonOwning) { mNonOwning = nonOwning; } int compute(int input) { if (!mNonOwning) { return -1; } return input * *mNonOwning; } int* mNonOwning; }; class HolderTest { public: HoldsNonOwning holder; int compute(); }; int HolderTest::compute() { int nonOwning = 2; holder.reset(&nonOwning); int i = holder.compute(42); // If we uncomment this we don't get the warning // std::cout << i << "\n"; return i; } int main(int, char**) { HolderTest ht; int i = ht.compute(); std::cout << i << "\n"; return 0; } ``` The -Wdangling-pointer gets triggered on this reasonable code. The pointer is non-owning.
[Bug c++/108499] New: False positive -Warray-bounds
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108499 Bug ID: 108499 Summary: False positive -Warray-bounds Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: steveire at gmail dot com Target Milestone: --- ``` #include class MyStruct { public: std::vector const& refAccessor(); std::size_t getSize(); }; void emitsWarning() { MyStruct params; auto unusedThing = params.refAccessor(); (void)unusedThing; auto const theSize = params.getSize(); std::vector initialVelocities(theSize, 0.0); initialVelocities.back() = 6; std::vector initialJoints(theSize, 0.0); initialJoints.back() = 5; } ``` -Werror=array-bounds -O2 ``` : In function 'void emitsWarning()': :20:27: error: array subscript -1 is outside array bounds of 'double [1152921504606846975]' [-Werror=array-bounds] 20 | initialVelocities.back() = 6; | ~~^~ cc1plus: some warnings being treated as errors Compiler returned: 1 ``` https://gcc.godbolt.org/z/sYrK6o54a
[Bug tree-optimization/108499] False positive -Warray-bounds
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108499 --- Comment #2 from Stephen --- > There is no way to figure out for the compiler that theSize is not zero > either. There is no way for the compiler to figure out that theSize *is* zero. We have warnings -Wmaybe-uninitialized and -Wuninitialized. This warning is -Warray-bounds, not -Wmaybe-array-bounds. This warning should not be emitted.
[Bug tree-optimization/108499] False positive -Warray-bounds
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108499 --- Comment #3 from Stephen --- False positives with this will just lead to proliferation of -Wno-array-bounds, which doesn't help.
[Bug c++/108197] New: -Wstringop-overread emitted on simple boost small_vector code
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108197 Bug ID: 108197 Summary: -Wstringop-overread emitted on simple boost small_vector code Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: steveire at gmail dot com Target Milestone: --- ``` #include struct MyThing { int d0 = {}; }; void modify(boost::container::small_vector &pp) { pp.resize(1); pp[0].d0 = 3; } void foo() { boost::container::small_vector pp2; boost::container::small_vector pp; pp.resize(1); pp[0].d0 = 2; pp2 = std::move(pp); } ``` gives ``` /opt/compiler-explorer/libs/boost_1_80_0/boost/container/detail/copy_move_algo.hpp:184:19: warning: 'void* __builtin_memcpy(void*, const void*, long unsigned int)' reading between 41 and 9223372036854775804 bytes from a region of size 40 [-Wstringop-overread] 184 | std::memmove(dest_raw, beg_raw, sizeof(value_type)*n); ``` https://godbolt.org/z/rs3oj3YoE Even though modify is never called, it must be in the code to reproduce the bug.
[Bug tree-optimization/108197] [12/13 Regression] -Wstringop-overread emitted on simple boost small_vector code
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108197 --- Comment #2 from Stephen --- Richard, are you saying this a bug in the boost code? It's not quite clear to me from your message. Can you be more specific about what the bug is in that case?
[Bug c++/105968] New: GCC vectorizes but reports that it did not vectorize
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105968 Bug ID: 105968 Summary: GCC vectorizes but reports that it did not vectorize Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: steveire at gmail dot com Target Milestone: --- I'm looking for a way to know if GCC autovectorizes some code. Starting with this testcase which I picked up somewhere: ``` #define N 1 #define NTIMES 10 double a[N] __attribute__ ((aligned (16))); double b[N] __attribute__ ((aligned (16))); double c[N] __attribute__ ((aligned (16))); double r[N] __attribute__ ((aligned (16))); int muladd (void) { int i, times; for (times = 0; times < NTIMES; times++) { #if 1 // count up for (i = 0; i < N; ++i) r[i] = (a[i] + b[i]) * c[i]; #else // count down (old gcc won't auto-vectorize) for (i = N-1; i >= 0; --i) r[i] = (a[i] + b[i]) * c[i]; #endif } return 0; } ``` the command ``` g++ -O2 -ftree-vectorize -fno-verbose-asm -mavx2 -fopt-info-vec-all -c test.cpp ``` reports ``` test.cpp:9:5: note: vectorized 1 loops in function. ``` However, with -O3, GCC reports that it did not vectorize: ``` g++ -O3 -ftree-vectorize -fno-verbose-asm -mavx2 -fopt-info-vec-all -c test.cpp ``` output: ``` test.cpp:9:5: note: vectorized 0 loops in function. ``` even though vector instructions are generated. Demo https://godbolt.org/z/3o41r7jWc
[Bug c++/96117] Cannot mix c++11-style and GCC-style attributes on struct in one specific location
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96117 Stephen changed: What|Removed |Added Resolution|--- |FIXED Status|NEW |RESOLVED --- Comment #3 from Stephen --- This seems to be fixed in the latest release https://godbolt.org/z/Kdsrs76PT https://developers.redhat.com/articles/2023/06/21/new-c-features-gcc-13#additional_updates