question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG]: Missing GCC output with std::atomic and "compile to binary"

See original GitHub issue

Describe 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 image

If I remove the use of std::atomic (that is, if a becomes an ordinary int), it works. https://godbolt.org/z/MbP1xofEo image

If I keep std:.atomic but disable the “compile to binary flag”, it works. https://godbolt.org/z/vr1ooT3E5

image

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:closed
  • Created 2 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
dkmcommented, Dec 31, 2021

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 😃

0reactions
dkmcommented, Jan 16, 2022

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 with objdump -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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found