public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/66282] New: Missing x86 floating point conversion on explicit casts violates C standard
@ 2015-05-25 21:27 timo.kreuzer at reactos dot org
  2015-05-25 22:07 ` [Bug c/66282] " pinskia at gcc dot gnu.org
  2015-05-29 16:49 ` jsm28 at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: timo.kreuzer at reactos dot org @ 2015-05-25 21:27 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66282

            Bug ID: 66282
           Summary: Missing x86 floating point conversion on explicit
                    casts violates C standard
           Product: gcc
           Version: 4.7.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: timo.kreuzer at reactos dot org
  Target Milestone: ---

When compiling floating point code, the compiler omits to convert an
intermediate computation result, which is cast to double, to 64 bit precision
and instead keeps the internal 80 bit precision.

Example code:

void bugbug()
{
    double x = 4.4;
    double y;

    y = (1 / x);
    if ( y != ((double)(1 / x)) )
    {
        printf("Standard violation!\n");
    }
}

compiled with "gcc.exe -Wall -g -c fpu.c -o fpu.o"

The expression on the right side inside the if() is not converted to double
precision, which is in violation of the C standard.

Quote:
"Implementations employing wide registers have to take care to honor
appropriate
semantics. Values are independent of whether they are represented in a register
or in memory. For example, an implicit spilling of a register is not permitted
to alter the value. Also, an explicit store and load is required to round to
the precision of the storage type. In particular, casts and assignments are
required to perform their specified conversion."

Emphasis is on the last sentence.

This was tested on a mingw version of the compiler, but I do not think this is
mingw specific.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c/66282] Missing x86 floating point conversion on explicit casts violates C standard
  2015-05-25 21:27 [Bug c/66282] New: Missing x86 floating point conversion on explicit casts violates C standard timo.kreuzer at reactos dot org
@ 2015-05-25 22:07 ` pinskia at gcc dot gnu.org
  2015-05-29 16:49 ` jsm28 at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2015-05-25 22:07 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66282

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I think 4.9 and above implement this semantics.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c/66282] Missing x86 floating point conversion on explicit casts violates C standard
  2015-05-25 21:27 [Bug c/66282] New: Missing x86 floating point conversion on explicit casts violates C standard timo.kreuzer at reactos dot org
  2015-05-25 22:07 ` [Bug c/66282] " pinskia at gcc dot gnu.org
@ 2015-05-29 16:49 ` jsm28 at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2015-05-29 16:49 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66282

Joseph S. Myers <jsm28 at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #2 from Joseph S. Myers <jsm28 at gcc dot gnu.org> ---
To discard intermediate excess precision, use -fexcess-precision=standard or an
option implying it such as -ansi or -std=c99 or -std=c11.

*** This bug has been marked as a duplicate of bug 323 ***


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-05-29 16:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-25 21:27 [Bug c/66282] New: Missing x86 floating point conversion on explicit casts violates C standard timo.kreuzer at reactos dot org
2015-05-25 22:07 ` [Bug c/66282] " pinskia at gcc dot gnu.org
2015-05-29 16:49 ` jsm28 at gcc dot gnu.org

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