[Bug c++/96511] New: Incorrect placement-new warning
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96511 Bug ID: 96511 Summary: Incorrect placement-new warning Product: gcc Version: 10.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: mserdarsanli at gmail dot com Target Milestone: --- Below code causes the warning in the last line, which seems to be incorrect. It affects all versions starting from GCC 8 Compiler explorer: https://godbolt.org/z/xhf6cr #include struct Foo { Foo() = default; Foo(int _a) : a(_a) {} int a = 0; }; void f() { Foo arr[2]; new (arr) Foo(10); // ok new (arr + 0) Foo(10); // ok new (&arr[0]) Foo(10); // ok new (&arr[1]) Foo(15); // ok new (arr + 1) Foo(15); // warning: placement new constructing an object of type 'Foo' and size '4' in a region of type 'Foo [2]' and size '0' [-Wplacement-new=] }
[Bug tree-optimization/92180] New: Missed optimization on casting __builtin_ia32_rdtsc result to int32
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92180 Bug ID: 92180 Summary: Missed optimization on casting __builtin_ia32_rdtsc result to int32 Product: gcc Version: 9.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: mserdarsanli at gmail dot com Target Milestone: --- Link: https://godbolt.org/z/wcIN0a #include uint32_t foo1() { return __builtin_ia32_rdtsc(); } uint64_t foo2() { return __builtin_ia32_rdtsc(); } Generates assembly: foo1(): rdtsc sal rdx, 32 or rax, rdx ret foo2(): rdtsc sal rdx, 32 or rax, rdx ret While clang generates better code for foo1 foo1(): # @foo1() rdtsc ret
[Bug tree-optimization/91409] New: Missed optimization on `labels as values` expression
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91409 Bug ID: 91409 Summary: Missed optimization on `labels as values` expression Product: gcc Version: 9.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: mserdarsanli at gmail dot com Target Milestone: --- I recently posted about this on SO, but it did not gain much traction: https://stackoverflow.com/questions/55987401/gcc-clang-labels-as-values-computing-offsets-at-runtime The missed optimization is when using `labels as values` feature and computing address difference. The expression `&&label2 - &&label1` generates code that does the subtraction on runtime, while it might be possible to compute it on compile time. Godbolt link: https://godbolt.org/z/zZdFYo
[Bug tree-optimization/91019] New: Missed optimization on sequential memcpy calls
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91019 Bug ID: 91019 Summary: Missed optimization on sequential memcpy calls Product: gcc Version: 9.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: mserdarsanli at gmail dot com Target Milestone: --- #include #include void encode_v1(uint8_t *buf, uint64_t a1, uint16_t a2) { memcpy(buf, &a1, 6); memcpy(buf+6, &a2, 2); } void encode_v2(uint8_t *buf, uint64_t a1, uint16_t a2) { memcpy(buf, &a1, 8); memcpy(buf+6, &a2, 2); } Two functions above should be equivalent, packing arguments into buffer. `encode_v1` copies 6 bytes, then 2 bytes. `encode_v2` copies 8 bytes, then replaces last two bytes. Functionally they are the same, while v2 generates better assembly. This is the assembly with -O3 (https://godbolt.org/z/i6TMiY) encode_v1(unsigned char*, unsigned long, unsigned short): mov eax, esi shr rsi, 32 mov WORD PTR [rdi+6], dx mov DWORD PTR [rdi], eax mov WORD PTR [rdi+4], si ret encode_v2(unsigned char*, unsigned long, unsigned short): mov QWORD PTR [rdi], rsi mov WORD PTR [rdi+6], dx ret
[Bug middle-end/54202] Overeager warning about freeing non-heap objects
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54202 Serdar Sanli changed: What|Removed |Added CC||mserdarsanli at gmail dot com --- Comment #9 from Serdar Sanli --- A simpler example not involving any globals, causing Wfree-nonheap-object warning since GCC11 https://godbolt.org/z/MYn1zrjE4 === struct Foo { void allocate(int n); void deallocate(); int *_data; }; void Foo::allocate(int n) { _data = new int[n] - 1; } void Foo::deallocate() { delete[] (_data+1); }
[Bug c++/108587] New: `decltype(x) x;` in struct declaration causes "changes meaning of" error
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108587 Bug ID: 108587 Summary: `decltype(x) x;` in struct declaration causes "changes meaning of" error Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: mserdarsanli at gmail dot com Target Milestone: --- Godbolt link: https://godbolt.org/z/rjEGPKcE7 void fine() { int x; struct { int x; } v = { .x = x, }; } void not_fine() { int x; struct { decltype(x) x; // error: declaration of 'int not_fine()x' changes meaning of 'x' [-fpermissive] } v = { .x = x, }; }
[Bug c++/108597] New: internal compiler error with -Wduplicated-cond
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108597 Bug ID: 108597 Summary: internal compiler error with -Wduplicated-cond Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: mserdarsanli at gmail dot com Target Milestone: --- https://godbolt.org/z/Kdvd5hzYK compile below with -Wduplicated-cond and it will crash template struct MyStruct { void check(int &x) { if (&x == &_a) { } else if (&x == &_b) { } } int _a; int _b; };
[Bug c++/108597] internal compiler error with -Wduplicated-cond
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108597 --- Comment #1 from Serdar Sanli --- stacktrace from my gcc 12.2.0: 0xe2534f crash_signal /root/source/gcc-12.2.0/gcc/toplev.cc:322 0xb0f049 location_wrapper_p(tree_node const*) /root/source/gcc-12.2.0/gcc/tree.h:4160 0xb0f049 tree_strip_any_location_wrapper(tree_node*) /root/source/gcc-12.2.0/gcc/tree.h:4172 0xb0f049 operand_compare::operand_equal_p(tree_node const*, tree_node const*, unsigned int) /root/source/gcc-12.2.0/gcc/fold-const.cc:2987 0xb100fb operand_compare::operand_equal_p(tree_node const*, tree_node const*, unsigned int) /root/source/gcc-12.2.0/gcc/fold-const.cc:3363 0xb0f3f1 operand_compare::operand_equal_p(tree_node const*, tree_node const*, unsigned int) /root/source/gcc-12.2.0/gcc/fold-const.cc:3227 0x9a6f07 warn_duplicated_cond_add_or_warn(unsigned int, tree_node*, vec**) /root/source/gcc-12.2.0/gcc/c-family/c-warn.cc:2537 0x894e18 cp_parser_selection_statement /root/source/gcc-12.2.0/gcc/cp/parser.cc:13108 0x86f5d5 cp_parser_statement /root/source/gcc-12.2.0/gcc/cp/parser.cc:12296 0x893fe1 cp_parser_implicitly_scoped_statement /root/source/gcc-12.2.0/gcc/cp/parser.cc:14423 0x895239 cp_parser_selection_statement /root/source/gcc-12.2.0/gcc/cp/parser.cc:13186 0x86f5d5 cp_parser_statement /root/source/gcc-12.2.0/gcc/cp/parser.cc:12296 0x87016d cp_parser_statement_seq_opt /root/source/gcc-12.2.0/gcc/cp/parser.cc:12850 0x87021f cp_parser_compound_statement /root/source/gcc-12.2.0/gcc/cp/parser.cc:12802 0x88ec73 cp_parser_function_body /root/source/gcc-12.2.0/gcc/cp/parser.cc:25071 0x88ec73 cp_parser_ctor_initializer_opt_and_function_body /root/source/gcc-12.2.0/gcc/cp/parser.cc:25122 0x88fdbe cp_parser_function_definition_after_declarator /root/source/gcc-12.2.0/gcc/cp/parser.cc:31257 0x8900e3 cp_parser_late_parsing_for_member /root/source/gcc-12.2.0/gcc/cp/parser.cc:32189 0x86a06e cp_parser_class_specifier_1 /root/source/gcc-12.2.0/gcc/cp/parser.cc:26190 0x86af46 cp_parser_class_specifier /root/source/gcc-12.2.0/gcc/cp/parser.cc:26214
[Bug c++/108613] New: GCC12 internal compiler error on __int128_t in type_traits header
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108613 Bug ID: 108613 Summary: GCC12 internal compiler error on __int128_t in type_traits header Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: mserdarsanli at gmail dot com Target Milestone: --- https://godbolt.org/z/M1o34e6cx Below code crashes GCC versions starting with GCC 12. It is only stuff from std library headers, I've copied bits from preprocessed output. template< class > struct remove_cv; template< class _Tp> using __remove_cv_t = typename remove_cv< _Tp> ::type; template< class _Tp, _Tp __v> struct integral_constant { static constexpr inline _Tp value = (__v); typedef _Tp value_type; typedef integral_constant type; constexpr operator value_type() const noexcept { return value; } constexpr value_type operator()() const noexcept { return value; } }; using false_type = integral_constant< bool, false> ; template< class ...> struct __or_; template<> struct __or_< > : public false_type {}; template< class , class > struct is_same; template< class _Tp, class ..._Types> using __is_one_of = __or_< is_same< _Tp, _Types> ...> ; template< class _Tp> using __is_signed_integer = __is_one_of< _Tp , signed char, signed short, signed int, signed long, signed long long, signed __int128_t> ; --- Stacktrace: 0xe2534f crash_signal /root/source/gcc-12.2.0/gcc/toplev.cc:322 0x7c0535 grokdeclarator(cp_declarator const*, cp_decl_specifier_seq*, decl_context, int, tree_node**) /root/source/gcc-12.2.0/gcc/cp/decl.cc:12373 0x7c73fc groktypename(cp_decl_specifier_seq*, cp_declarator const*, bool) /root/source/gcc-12.2.0/gcc/cp/decl.cc:5514 0x8797d5 cp_parser_type_id_1 /root/source/gcc-12.2.0/gcc/cp/parser.cc:24250 0x87c4f3 cp_parser_template_type_arg /root/source/gcc-12.2.0/gcc/cp/parser.cc:24272 0x87c659 cp_parser_template_argument /root/source/gcc-12.2.0/gcc/cp/parser.cc:18803 0x87c659 cp_parser_template_argument_list /root/source/gcc-12.2.0/gcc/cp/parser.cc:18727 0x87c659 cp_parser_enclosed_template_argument_list /root/source/gcc-12.2.0/gcc/cp/parser.cc:32059 0x87da7f cp_parser_template_id /root/source/gcc-12.2.0/gcc/cp/parser.cc:18266 0x87e239 cp_parser_class_name /root/source/gcc-12.2.0/gcc/cp/parser.cc:25713 0x875d8e cp_parser_qualifying_entity /root/source/gcc-12.2.0/gcc/cp/parser.cc:7116 0x875d8e cp_parser_nested_name_specifier_opt /root/source/gcc-12.2.0/gcc/cp/parser.cc:6798 0x88cf6c cp_parser_simple_type_specifier /root/source/gcc-12.2.0/gcc/cp/parser.cc:19765 0x86aea5 cp_parser_type_specifier /root/source/gcc-12.2.0/gcc/cp/parser.cc:19424 0x87b3d0 cp_parser_type_specifier_seq /root/source/gcc-12.2.0/gcc/cp/parser.cc:24364 0x879744 cp_parser_type_id_1 /root/source/gcc-12.2.0/gcc/cp/parser.cc:24164 0x87c117 cp_parser_type_id /root/source/gcc-12.2.0/gcc/cp/parser.cc:24260 0x87c117 cp_parser_alias_declaration /root/source/gcc-12.2.0/gcc/cp/parser.cc:21778 0x897f37 cp_parser_template_declaration_after_parameters /root/source/gcc-12.2.0/gcc/cp/parser.cc:31316 0x89827a cp_parser_explicit_template_declaration /root/source/gcc-12.2.0/gcc/cp/parser.cc:31598
[Bug c++/108613] [12/13 Regression] GCC12 internal compiler error on __int128_t in type_traits header
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108613 --- Comment #6 from Serdar Sanli --- > Where did you get this from? The header uses signed __int128 > here, not signed __int128_t. Just checked and __GLIBCXX_TYPE_INT_N_0 is also __int128 for me. int128_t seem to come from somewhere else, in my case it is in cuda compiler generated code. Sorry for not being clear and wasting time, snippet I copied was only intended as a repro, not as a bug report on stdlibc++.
[Bug c++/119467] New: Missed optimization on wrapping builtin function
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119467 Bug ID: 119467 Summary: Missed optimization on wrapping builtin function Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: mserdarsanli at gmail dot com Target Milestone: --- Compiling below wrapper function ``` double powi(double a, int x) { return __builtin_powi(a, x); } ``` generates assembly below: ``` powi(double, int): sub rsp, 8 call__powidf2 add rsp, 8 ret ``` while if I replace calleee with any other function, it generates better code with single jmp instruction: ``` extern double another_func(double a, int x); double powi(double a, int x) { return another_func(a, x); } ``` generates: ``` powi(double, int): jmp another_func(double, int) ```