[Bug tree-optimization/105867] [12/13 Regression] incorrect dangling-pointer warning
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105867 Gustaw Smolarczyk changed: What|Removed |Added CC||wielkiegie at gmail dot com --- Comment #5 from Gustaw Smolarczyk --- This warning is triggered just by std::set::swap(std::set&) when optimizing. https://godbolt.org/z/e84xPMdf6 #include void foo() { std::set x, y; x.swap(y); }
[Bug tree-optimization/105329] [12/13 Regression] Bogus restrict warning when assigning 1-char string literal to std::string since r12-3347-g8af8abfbbace49e6
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105329 Gustaw Smolarczyk changed: What|Removed |Added CC||wielkiegie at gmail dot com --- Comment #30 from Gustaw Smolarczyk --- I have encountered a similar bug, reproducer: #include std::string foo() { return "_" + std::to_string(0); }
[Bug libstdc++/105258] New: std::get_temporary_buffer() does not respect alignment (affects std::stable_sort())
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105258 Bug ID: 105258 Summary: std::get_temporary_buffer() does not respect alignment (affects std::stable_sort()) Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: wielkiegie at gmail dot com Target Milestone: --- Created attachment 52795 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52795=edit The reproducer The `std::get_temporary_buffer()` function uses raw `operator new()` to allocate enough memory for the `sizeof(T) * count` bytes. However, it does not take `alignof(T)` into account. While `std::get_temporary_buffer()` is deprecated in C++17 [1], it is still used internally by `std::stable_sort()`. The issue is reproducible on the gcc HEAD [2]. Please note that the alignment issues might not be deterministic as the allocator can return an allocation of correct alignment by accident. For convenience, I have also attached the reproducer to this bug report. [1] https://en.cppreference.com/w/cpp/memory/get_temporary_buffer [2] https://wandbox.org/permlink/zZt6Weh3V1XWmUWt
[Bug middle-end/91490] [9 Regression] bogus argument missing terminating nul warning on strlen of a flexible array member
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91490 Gustaw Smolarczyk changed: What|Removed |Added CC||wielkiegie at gmail dot com --- Comment #8 from Gustaw Smolarczyk --- Bug 96934 is potentially related to this issue, but I have also found a miscompilation of strcmp call that is possibly related.
[Bug c++/96934] Copy initialization of struct involving aggregate array initialization miscompiles in GCC 9
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96934 --- Comment #1 from Gustaw Smolarczyk --- It seems that part of this issue was already reported in another bug report (though the report is about flexible array members, the comment does not reference them): https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91490#c6 However, I don't see any mention of the miscompilation in the thread. Possibly the issue didn't surface in comment 6 as the tested string has only a single character (+ the terminating null character). Or strcmp is needed in order to trigger it.
[Bug c++/96934] New: Copy initialization of struct involving aggregate array initialization miscompiles in GCC 9
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96934 Bug ID: 96934 Summary: Copy initialization of struct involving aggregate array initialization miscompiles in GCC 9 Product: gcc Version: 9.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: wielkiegie at gmail dot com Target Milestone: --- GCC 9 (but not <= 8 and not >= 10, including trunk) miscompiles the following piece of code. I have tested GCC 9.1 (which produces even worse code, as it assumes the const char* has only a single character) and GCC 9.2, 9.3 (explained below). I was not able to test the current GCC 9 branch. Test case: https://godbolt.org/z/jPq4h7 The Code struct holds an array of chars that is meant to be always null-terminated. A simple constructor is provided to simulate how the array should be initialized (this is a reduced real world scenario). It uses aggregate initialization in order to store the "12" string. There are two problems, probably originating from the same underlying issue: 1. Bogus -Wstringop-overflow warning saying the _buffer is unterminated, while it most certainly is (as you can see in the assembly). 2. std::strcmp call miscompiled as if _buffer == "1" (and not "12"). Switching the TEST define on line 17 into T1, T2, T3, T4 doesn't change the outcome. However, T5 and T6 fix the issue. What seems to be the difference is the copy-initialization [1] being involved in T1 and T2 (and T3, T4 "inheriting" the buggy state). T5 doesn't do copy-initialization, and T6 just copies it. [1] https://en.cppreference.com/w/cpp/language/copy_initialization
[Bug c++/89576] New: constexpr not working if implicitly captured in a lambda in a function template (gcc 8.3+)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89576 Bug ID: 89576 Summary: constexpr not working if implicitly captured in a lambda in a function template (gcc 8.3+) Product: gcc Version: 8.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: wielkiegie at gmail dot com Target Milestone: --- There are many similar bugs that I have found in the bugzilla (see below), but this one differs from the other ones: 1. It happens only in gcc 8.3 and trunk (gcc 8.2 and earlier are fine) 2. The lambda is not generic (but it is contained in a function template which might be similar internally) 3. The capture is implicit Example to reproduce: template void foo() { constexpr int x = 0; [&] { if constexpr (x) {} }; } Produces the following in gcc 8.3 and trunk: : In lambda function: :6:24: error: lambda capture of 'x' is not a constant expression if constexpr (x) {} ^ The following changes to the example make it compile: 1. Adding static to the constexpr int 2. Making it a regular function and not a template 3. Removing the [&] capture Changing the capture from [&] to [=] doesn't help. If I change it to an explicit capture [x], it fails in all gcc versions except gcc 7.4 and passes on clang. The other similar bug reports: bug 86429, bug 82643
[Bug c++/81860] [7 Regression] Call to undefined inline function involving inheriting constructors
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81860 --- Comment #8 from Gustaw Smolarczyk --- Hello, Can I expect the fix to be backported to the gcc 7 branch? gcc 7.3.0 has apparently shipped with the bug still present.
[Bug tree-optimization/82060] New: [7/8 Regression] ICE in refs_may_alias_p_1 with devirtualization enabled
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82060 Bug ID: 82060 Summary: [7/8 Regression] ICE in refs_may_alias_p_1 with devirtualization enabled Product: gcc Version: 7.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: wielkiegie at gmail dot com Target Milestone: --- Created attachment 42095 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42095=edit Annotated test case used in order to reproduce the bug Attached is a minimal test case that triggers an Internal Compiler Error in refs_may_alias_p_1 when compiling at least with -O1 -fdevirtualize. The bug occurs on gcc 7 and the current snapshot (tested on godbolt). I have tried to check which -O1 optimization is needed alongside -fdevirtualize in order to trigger this bug, but when I replaced -O1 with a list of -f options from the gcc manual the bug went away. I also tried to list the -O1 optimizations using `-Q --help=optimizers', but it didn't help. It might be something not listed there or otherwise hidden inside the -O1 setting. Comments in the test case show what is needed in order to encounter this bug. Some of these might be erroneous, but if I tried to simplify/change any of these, the bug goes away. $ g++ -O1 -fdevirtualize testcase.cpp testcase.cpp: In function ‘void foo(D&)’: testcase.cpp:30:1: internal compiler error: in refs_may_alias_p_1, at tree-ssa-alias.c:1538 } ^ 0xbd1e49 refs_may_alias_p_1(ao_ref*, ao_ref*, bool) ../../gcc/tree-ssa-alias.c:1538 0xbd3369 stmt_may_clobber_ref_p_1(gimple*, ao_ref*) ../../gcc/tree-ssa-alias.c:2289 0xbd3b0a walk_aliased_vdefs_1 ../../gcc/tree-ssa-alias.c:2947 0xbd3b9d walk_aliased_vdefs_1 ../../gcc/tree-ssa-alias.c:2934 0xbd3c41 walk_aliased_vdefs(ao_ref*, tree_node*, bool (*)(ao_ref*, tree_node*, void*), void*, bitmap_head**, bool*, unsigned int) ../../gcc/tree-ssa-alias.c:2970 0x96d2ec ipa_polymorphic_call_context::get_dynamic_type(tree_node*, tree_node*, tree_node*, gimple*) ../../gcc/ipa-polymorphic-call.c:1680 0xc43392 eliminate_dom_walker::before_dom_children(basic_block_def*) ../../gcc/tree-ssa-pre.c:4604 0x10fe12a dom_walker::walk(basic_block_def*) ../../gcc/domwalk.c:265 0xc42c01 eliminate ../../gcc/tree-ssa-pre.c:4773 0xc42f44 execute ../../gcc/tree-ssa-pre.c:5207 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions.
[Bug c++/81860] New: Call to undefined inline function involving inheriting constructors
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81860 Bug ID: 81860 Summary: Call to undefined inline function involving inheriting constructors Product: gcc Version: 7.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: wielkiegie at gmail dot com Target Milestone: --- Created attachment 41987 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41987=edit Minimized test case that reproduces the issue It seems that gcc forgets to emit or inline an empty inline constructor when the following are used: 1. An empty template class A with empty constructor A() {} that is the one that is missed 2. A class B with a template constructor (doesn't matter what is templated) that accepts an object of class A with a default argument A() and stores it inside of itself 3. A class C that derives from class B and uses inheriting constructors Attached is a test-case for this. $ g++ test-case3.cpp /tmp/ccoFntWy.o: In function `main': test-case3.cpp:(.text+0x11): undefined reference to `A::A()' collect2: error: ld returned 1 exit status The problem does occur on gcc 7 and the newest snapshot (tested on godbolt). It does not occur on gcc 6 and gcc 5. As such, it's a regression that first occurs in gcc 7.
[Bug c++/69035] New: [constexpr] Using bultins sometimes make the expression non-constant
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69035 Bug ID: 69035 Summary: [constexpr] Using bultins sometimes make the expression non-constant Product: gcc Version: 5.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: wielkiegie at gmail dot com Target Milestone: --- Hello, I have a problem when using builtins (like __builtin_clz()) inside constexpr functions. Example: constexpr int foo(int x) { return __builtin_clz(x); } Using foo() as a constant-expression results in the following error: char tab[foo(1)]; // error: size of array ‘tab’ is not an integral constant-expression However, if I add something to the foo(1) (and this something is not zero) it starts to work: char tab[foo(1)+1]; // no error. Using __builtin_clz() directly also works: char tab[__builtin_clz(1)]; // no error. As does adding 1 inside foo(): constexpr int foo2(int x) { return __builtin_clz(x) + 1; } char tab[foo(1)]; // no error. The clang compiler does not produce these errors and works with every example provided here.
[Bug c++/58193] New: init_priority attribute doesn't work on non-class types
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58193 Bug ID: 58193 Summary: init_priority attribute doesn't work on non-class types Product: gcc Version: 4.8.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: wielkiegie at gmail dot com __attribute__ ((init_priority (x))) makes it possible to order the initialization of global objects. However, gcc rejects this attribute on globals of non-class (or struct) types. It is still possible for gcc to emit a constructor in .init_array section when non-class global is initialized by a function, but it's not possible to set priority of such initializer. $ cat i1.cpp extern int bar(); const int foo __attribute__ ((init_priority (1000))) = bar(); $ g++ i1.cpp -c i1.cpp:3:52: error: can only use ‘init_priority’ attribute on file-scope definitions of objects of class type const int foo __attribute__ ((init_priority (1000))) = bar(); ^ $ The workaround for such a case is to wrap the type in struct. $ cat i2.cpp template typename Type class WrapInStruct { public: WrapInStruct() : _value() {} WrapInStruct(const Type value) : _value(value) {} operator Type() const { return _value; } private: Type _value; }; extern int bar(); const WrapInStructint foo __attribute__ ((init_priority (1000))) = bar(); $ g++ i2.cpp -c $