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

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).