[Bug lto/115327] New: [ld] [lto] using ld and lto, crash while dynamic compile executable
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115327 Bug ID: 115327 Summary: [ld] [lto] using ld and lto, crash while dynamic compile executable Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: lto Assignee: unassigned at gcc dot gnu.org Reporter: hanwei62 at huawei dot com Target Milestone: --- using lto and ld in arm, crash finally dynamic compile executable. code: 20081204-2_1.C ``` namespace { class c { public: c () {} virtual ~c() {} }; }; void foo (void) { c x; } ``` clang++ -fuse-ld=ld -Wno-unused-command-line-argument -Wno-deprecated -fno-caret-diagnostics -fdiagnostics-color=never -fmessage-length=0 -flto -c -o cp_lto_20081204-2_1.o 20081204-2_1.C 20081204-2_0.C ``` extern void foo (void); int main () { foo (); return 0; } ``` clang++ -fuse-ld=ld -Wno-unused-command-line-argument -Wno-deprecated -fno-caret-diagnostics -fdiagnostics-color=never -fmessage-length=0 -flto -c -o cp_lto_20081204-2_0.o 20081204-2_0.C finally: ``` clang++ cp_lto_20081204-2_0.o cp_lto_20081204-2_1.o -fuse-ld=ld -Wno-unused-command-line-argument -Wno-deprecated -fno-caret-diagnostics -fdiagnostics-color=never -fmessage-length=0 -flto -o g++-dg-lto-20081204-2-01.exe clang-15: error: unable to execute command: Segmentation fault (core dumped) clang-15: error: linker command failed due to signal (use -v to see invocation) ``` ``` ld -v GNU ld 2.42 ``` But if I compile static, it passed.
[Bug target/114955] marco DATA_ALIGNMENT may conflict with pragma pack
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114955 --- Comment #5 from hanwei (K) --- You mean the pragma pack just apply to the inner members of struct, not the first member. The align of struct (first member also) is controlled by __attribute__((aligned(...))). Right?
[Bug target/114955] marco DATA_ALIGNMENT may conflict with pragma pack
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114955 --- Comment #3 from hanwei (K) --- Yeap, press return too soon. Code like: #include #pragma pack(1) char a_global[2] = {0,0}; int g_int[3] = {1, 2, 4}; char b_global[2] = {0, 0}; struct A { char c; long long a; int i; }; #pragma pack() struct TMP g_struct = {0}; --- We set pragma pack(1) hope the address of variable (also first member of struct) with struct A type align to 1. https://github.com/gcc-mirror/gcc/blame/ce343444c019f34172320d0873cc993d43750f41/gcc/config/aarch64/aarch64.h#L128 #define AARCH64_EXPAND_ALIGNMENT(COND, EXP, ALIGN) \ (((COND) && ((ALIGN) < BITS_PER_WORD) \ && (TREE_CODE (EXP) == ARRAY_TYPE \ || TREE_CODE (EXP) == UNION_TYPE\ || TREE_CODE (EXP) == RECORD_TYPE)) ? BITS_PER_WORD : (ALIGN)) force the mininal align of arrays, unions and structures (in aarch64 is 8) even if we set pragma pack for it. The address of global variable and static variable is implementation-defined, but the data align behavior of GCC seem conflict with pragma pack?
[Bug c/114955] New: marco DATA_ALIGNMENT may conflict with pragma pack
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114955 Bug ID: 114955 Summary: marco DATA_ALIGNMENT may conflict with pragma pack Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: hanwei62 at huawei dot com Target Milestone: ---
[Bug c/114763] Wduplicated-branches just check last else if-else case?
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114763 --- Comment #3 from hanwei (K) --- (In reply to Andrew Pinski from comment #1) > Note only the second case has if's 2 sides which are the same; > it is basically `a ? b : (c ? d : d)`. > > While the first case you have `a ? b : (c ? d : b)` which is not supposed to > warn about at all because the 2 sides are not the same. > > The reason is because that is how the grammar of C/C++ works. So, Wduplicated-branches just check bottom two branches actually. Because only the bottom two branches will same if we check followed the grammar of C/C++.
[Bug c/114763] Wduplicated-branches just check last else if-else case?
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114763 --- Comment #2 from hanwei (K) --- (In reply to Andrew Pinski from comment #1) > Note only the second case has if's 2 sides which are the same; > it is basically `a ? b : (c ? d : d)`. > > While the first case you have `a ? b : (c ? d : b)` which is not supposed to > warn about at all because the 2 sides are not the same. > > The reason is because that is how the grammar of C/C++ works. So, Wduplicated-branches just check bottom two branches actually. Because only the bottom two branches will same if we check followed the grammar of C/C++.
[Bug c/114763] New: Wduplicated-branches just check last else if-else case?
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114763 Bug ID: 114763 Summary: Wduplicated-branches just check last else if-else case? Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: hanwei62 at huawei dot com Target Milestone: --- This code: void foo(int x) { if (x) { x -= 2; } else if (x > 50) { x -= 2; } else x += 2; } # gcc -c test.c -Wduplicated-branches not warning, even if-else if branches is same. void foo(int x) { if (x) { x -= 2; } else if (x > 50) { x -= 2; } else if (x < 20) { x += 2; } else { x += 2; } } warning. Same like https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85094 What I find that Wduplicated-branches just check the last `else if-else` branches. https://godbolt.org/z/WP8v5P4Yf It's misleading.