[Bug c++/111436] New: Wrong code when bit-casting struct through pointer
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111436 Bug ID: 111436 Summary: Wrong code when bit-casting struct through pointer Product: gcc Version: 12.3.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: josopait at goopax dot com Target Milestone: --- Does gcc produce wrong code here? The program below is part of a bitwise conversion mechanism, similar to std::bit_cast, but for more general types. The output should be: from=17,23 to=17,23 But with -O2 or higher the output is: from=17,23 to=0,0 I tried with gcc 12, 13, and 14 on x86_64 linux. #include #include #include using namespace std; template inline void reinterpret_switch3(TO& to, const FROM& from) { to = *reinterpret_cast(&from); } template inline void reinterpret_switch2(TO& to, const FROM& from) { reinterpret_switch3(to, array({ { from } })); } template inline void reinterpret_switch(TO& to, const FROM& from) { array tmp; reinterpret_switch2(tmp, from); to = tmp[0]; } int main(int argc, char** argv) { pair from = {17, 23}; pair to; reinterpret_switch(to, from); cout << "from=" << from.first << "," << from.second << endl; cout << "to=" << to.first << "," << to.second << endl; }
[Bug libbacktrace/112322] New: std::stacktrace fails
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112322 Bug ID: 112322 Summary: std::stacktrace fails Product: gcc Version: 12.3.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libbacktrace Assignee: unassigned at gcc dot gnu.org Reporter: josopait at goopax dot com CC: ian at gcc dot gnu.org Target Milestone: --- I installed gcc on gentoo linux: EXTRA_ECONF="--enable-libstdcxx-backtrace=yes" emerge gcc and compiled the following program: #include #include int main() { std::cout << std::stacktrace::current() << std::endl; } $ g++-13 -g -std=c++23 a.cpp -o a -lstdc++_libbacktrace When compiled with GCC 13 or GCC 14, the program output is weird: $ ./a 0# at :32764 1# at :32764 2# at :32764 3# at :32764 4# The number 32764 changes randomly between program calls, in the range 32764 .. 32767. When compiled with GCC 12, the program crashes with a segmentation fault: (gdb) bt #0 0x in ?? () #1 0xad41 in elf_nodebug (state=, pc=, callback=, data=, error_callback=) at elf.c:585 #2 elf_nodebug (state=, pc=, callback=, error_callback=, data=) at elf.c:565 #3 0x7c0f in std::stacktrace_entry::_M_get_info (this=0x5557e2b0, __desc=0x7fffdb60, __file=0x7fffdb80, __line=0x7fffdb5c) at /usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/stacktrace:191 #4 0x7db2 in std::operator<< (__os=..., __f=...) at /usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/stacktrace:722 #5 0x85ce in std::operator<< > (__os=..., __st=...) at /usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/stacktrace:737 #6 0x7492 in main () at a.cpp:8 Here, parameter `state` of function elf_nodebug points to: (gdb) p *__state $10 = {filename = 0x0, threaded = 1, lock = 0x0, fileline_fn = 0xa5f0 , fileline_data = 0x0, syminfo_fn = 0xa5d0 , syminfo_data = 0x0, fileline_initialization_failed = 0, lock_alloc = 0, freelist = 0x77fc4048} and error_callback is NULL, which causes the segmentation fault.
[Bug libstdc++/112498] New: std::is_convertible::value returns false
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112498 Bug ID: 112498 Summary: std::is_convertible::value returns false Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: josopait at goopax dot com Target Milestone: --- If I am not mistaken, this should succeed: #include int main() { static_assert(std::is_convertible::value); // ok static_assert(std::is_convertible::value); // fails }
[Bug c++/112498] std::is_convertible::value returns false
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112498 --- Comment #2 from Ingo Josopait --- Yes, you are right. It is confusing, though. Maybe the warning message should mention that it is actually invalid code. It looked more like a suggestion to me.