[BUG]: _Noreturn cancels printf
See original GitHub issueDescribe the bug
_Noreturn
cancels printf
.
Steps to reproduce
https://godbolt.org/z/efvMcnKeq
Expected behavior
Expected output:
xxx
zzz
Actual output:
<nothing>
Reproduction link
https://godbolt.org/z/efvMcnKeq
Screenshots
Not applicable
Operating System
No response
Browser version
No response
Issue Analytics
- State:
- Created a year ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Functions with "noreturn" attribute should not return
Unique rules to find Bugs, Vulnerabilities, Security Hotspots, ... Printf-style format strings should not lead to unexpected behavior at runtime. Bug ...
Read more >Function Attributes - Using the GNU Compiler Collection (GCC)
The following attributes are currently defined for functions on all targets: aligned , alloc_size , noreturn , returns_twice , noinline , noclone ...
Read more >_Noreturn function specifier in C - Tutorialspoint
The program terminates abnormally [Warning] function declared 'noreturn' has a 'return' statement. Now if it is a normal function it will ...
Read more >6.26. Declaring Attributes of Functions
The noreturn keyword tells the compiler to assume that fatal cannot return. It can then optimize without regard to what would happen if...
Read more >Bugs in C - The Craft of Coding
6 printf(“Enter a number: “). 7 scanf(“%d”, &a);. The gcc C compiler might generate the following error message: error.c: In function 'main':.
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
It’s undefined to return from a
_Noreturn
function, I’d say the expected behavior is anything from xxx zzz to summoning the Kraken 😛That being said the reason nothing happens to show up here is that stdout’s buffer isn’t flushed before the program segfaults. If you add
setvbuf(stdout, NULL, _IONBF, 0);
to main the output is:For glibc at least no flushing is performed https://code.woboq.org/userspace/glibc/stdlib/abort.c.html#abort