public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/61739] New: __builtin_printf optimization conflicts with POSIX semantics
@ 2014-07-08 0:37 bugdal at aerifal dot cx
2014-07-08 7:17 ` [Bug c/61739] " schwab@linux-m68k.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: bugdal at aerifal dot cx @ 2014-07-08 0:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61739
Bug ID: 61739
Summary: __builtin_printf optimization conflicts with POSIX
semantics
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: bugdal at aerifal dot cx
Created attachment 33086
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33086&action=edit
test case
Per POSIX,
"All functions that reference (FILE *) objects, except those with names ending
in _unlocked, shall behave as if they use flockfile() and funlockfile()
internally to obtain ownership of these (FILE *) objects."
Source:
http://pubs.opengroup.org/onlinepubs/9699919799/functions/flockfile.html
GCC's transformation that eliminates printf("") causes this requirement to be
ignored; the calling thread is allowed to proceed even if a lock on stdout held
by another thread should block printf.
The included test-case demonstrates the issue. It should deadlock, and indeed
it does with -fno-builtin. But with the default settings, the program
terminates normally.
Additional thoughts on the above POSIX requirement are on a blog post I wrote a
while back, http://ewontfix.com/8/
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/61739] __builtin_printf optimization conflicts with POSIX semantics
2014-07-08 0:37 [Bug c/61739] New: __builtin_printf optimization conflicts with POSIX semantics bugdal at aerifal dot cx
@ 2014-07-08 7:17 ` schwab@linux-m68k.org
2014-07-08 9:25 ` rguenth at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: schwab@linux-m68k.org @ 2014-07-08 7:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61739
--- Comment #1 from Andreas Schwab <schwab@linux-m68k.org> ---
Since printf("") does not need to obtain ownership of stdout there is no
conflict here. There is no requirement that it *must* obtain ownership even if
not needed.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/61739] __builtin_printf optimization conflicts with POSIX semantics
2014-07-08 0:37 [Bug c/61739] New: __builtin_printf optimization conflicts with POSIX semantics bugdal at aerifal dot cx
2014-07-08 7:17 ` [Bug c/61739] " schwab@linux-m68k.org
@ 2014-07-08 9:25 ` rguenth at gcc dot gnu.org
2014-07-08 14:37 ` bugdal at aerifal dot cx
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-07-08 9:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61739
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |INVALID
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Agreed.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/61739] __builtin_printf optimization conflicts with POSIX semantics
2014-07-08 0:37 [Bug c/61739] New: __builtin_printf optimization conflicts with POSIX semantics bugdal at aerifal dot cx
2014-07-08 7:17 ` [Bug c/61739] " schwab@linux-m68k.org
2014-07-08 9:25 ` rguenth at gcc dot gnu.org
@ 2014-07-08 14:37 ` bugdal at aerifal dot cx
2014-07-08 14:38 ` bugdal at aerifal dot cx
2014-07-11 18:47 ` bugdal at aerifal dot cx
4 siblings, 0 replies; 6+ messages in thread
From: bugdal at aerifal dot cx @ 2014-07-08 14:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61739
Rich Felker <bugdal at aerifal dot cx> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|INVALID |---
--- Comment #3 from Rich Felker <bugdal at aerifal dot cx> ---
Yes it does need to obtain ownership of the file: to set the orientation to
byte mode. This is required even by ISO C (without POSIX). A simpler test case:
printf("");
printf("%d\n", fwide(stdout));
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/61739] __builtin_printf optimization conflicts with POSIX semantics
2014-07-08 0:37 [Bug c/61739] New: __builtin_printf optimization conflicts with POSIX semantics bugdal at aerifal dot cx
` (2 preceding siblings ...)
2014-07-08 14:37 ` bugdal at aerifal dot cx
@ 2014-07-08 14:38 ` bugdal at aerifal dot cx
2014-07-11 18:47 ` bugdal at aerifal dot cx
4 siblings, 0 replies; 6+ messages in thread
From: bugdal at aerifal dot cx @ 2014-07-08 14:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61739
--- Comment #4 from Rich Felker <bugdal at aerifal dot cx> ---
Sorry, that should be:
printf("");
printf("%d\n", fwide(stdout, 0));
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/61739] __builtin_printf optimization conflicts with POSIX semantics
2014-07-08 0:37 [Bug c/61739] New: __builtin_printf optimization conflicts with POSIX semantics bugdal at aerifal dot cx
` (3 preceding siblings ...)
2014-07-08 14:38 ` bugdal at aerifal dot cx
@ 2014-07-11 18:47 ` bugdal at aerifal dot cx
4 siblings, 0 replies; 6+ messages in thread
From: bugdal at aerifal dot cx @ 2014-07-11 18:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61739
--- Comment #5 from Rich Felker <bugdal at aerifal dot cx> ---
I reopened this, but now that I'm reporting a new symptom that's independent of
the original symptom, I'm wondering whether I should file a separate bug report
for it, or continue the issue under this original report. Which way is best?
Both have the same fix (removing the invalid optimization or replacing it with
a valid one), but the user-visible erroneous behaviors are distinct.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-07-11 18:47 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-08 0:37 [Bug c/61739] New: __builtin_printf optimization conflicts with POSIX semantics bugdal at aerifal dot cx
2014-07-08 7:17 ` [Bug c/61739] " schwab@linux-m68k.org
2014-07-08 9:25 ` rguenth at gcc dot gnu.org
2014-07-08 14:37 ` bugdal at aerifal dot cx
2014-07-08 14:38 ` bugdal at aerifal dot cx
2014-07-11 18:47 ` bugdal at aerifal dot cx
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).