[BUG]: Missing GCC output with std::atomic and "compile to binary"
See original GitHub issueDescribe the bug
Hi friends. I was testing the following code with x86-64 gcc 11.2 and the -O3 flag:
#include <atomic>
int f(std::atomic<int>& a) {
return a++;
}
and f is not present in the output. https://godbolt.org/z/YdhnhhKP1
If I remove the use of std::atomic (that is, if a becomes an ordinary int), it works. https://godbolt.org/z/MbP1xofEo
If I keep std:.atomic but disable the “compile to binary flag”, it works. https://godbolt.org/z/vr1ooT3E5
Steps to reproduce
See above.
Expected behavior
The “compile to binary” should not hide information. As far as I can see, the flag’s main function is to show/hide the generated machine code. I could be wrong.
Reproduction link
See above.
Screenshots
See above.
Operating System
Windows 10
Browser version
Chrome / Firefox
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
GCC 5.2.0 fails to build with binary mode · Issue #92
I didn't realize this was compiler-dependent. It turns out that your gcc 5.1.0 can build -m32 binaries (http://goo.gl/ueH5tF), but no other compiler version ......
Read more >gcc doesn't create a binary file
I use gcc version 6.3.0 on Windows 10. ... No error message screenshot ... If you don't get a binary, then the compiler...
Read more >g++ module compile fails with '_Atomic' does not name a type
The problem is more general than Python: #include <stdatomic.h> fails in C++. Try to compiled atomic.cpp with g++, you will get the same...
Read more >Building Firmware Problems
Sounds like you are missing some files or your computer doesn't know where to look for them. stdatomic.h is part of GNU GCC...
Read more >GCC 12 Release Series — Changes, New Features, and Fixes
Fortran: OpenMP code using the omp_lib.h include file can no longer be compiled with -std=f95 but now requires at least -std=f2003 .
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes, currently CE does not support stopping after the assembler, and binary means linking to a correct executable. Stopping after assembler and be able to see relocations info was something I was willing to do in the past. I’ll look into that if there’s no urgency 😃
Sorry I wasn’t clear. Your initial report is not a bug and @Quuxplusone explained exactly was is happening (no main in your code, CE inserts a dummy one without any call to f, f is being removed). There’s nothing to fix in CE about this, everything is working as expected. To get your expected result, you can fix your code to have a main function that calls your f function. That’s what I did above, and that triggered a bug #3235 in the ASM parser. Fixing this bug won’t change anything to your initial code though. You can check this by simply doing it locally (copy paste your code in a file, add an empty main, run
gcc -o test test.cc
, disasm withobjdump -d test
), and you should also observe that f is missing.Another solution will be available when https://github.com/compiler-explorer/compiler-explorer/pull/3232 is ready.