public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/103980] New: -Wdouble-promotion triggers on s390x when it shouldn't.
@ 2022-01-11 20:02 rmaguire314 at gmail dot com
  2022-01-11 20:15 ` [Bug c/103980] " pinskia at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: rmaguire314 at gmail dot com @ 2022-01-11 20:02 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 103980
           Summary: -Wdouble-promotion triggers on s390x when it
                    shouldn't.
           Product: gcc
           Version: 10.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rmaguire314 at gmail dot com
  Target Milestone: ---

The file bug.c:

#include <stdio.h>

int main(void)
{
    float x = 1.0F;

    if (x == 0.0F)
        puts("Hi!");

    return 0;
}

Build with:
gcc -Wdouble-promotion bug.c -o test

No errors.

Build with:
gcc -Wdouble-promotion -std=c89 bug.c -o test

Produces:
bug.c: In function 'main':
bug.c:7:11: warning: implicit conversion from 'float' to 'double' to
match other operand of binary expression [-Wdouble-promotion]
    7 |     if (x == 0.0F)

This only occurs on the s390x architecture. arm64 and amd64 work normally.
I'm running Debian 11 s390x version via emulating and chroot (host is amd64).
GCC version:
gcc (Debian 10.2.1-6) 10.2.1 20210110

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

* [Bug c/103980] -Wdouble-promotion triggers on s390x when it shouldn't.
  2022-01-11 20:02 [Bug c/103980] New: -Wdouble-promotion triggers on s390x when it shouldn't rmaguire314 at gmail dot com
@ 2022-01-11 20:15 ` pinskia at gcc dot gnu.org
  2022-01-11 20:54 ` joseph at codesourcery dot com
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-11 20:15 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
              Build|                            |s390x-*-linux-gnu
           Keywords|                            |diagnostic
               Host|                            |s390x-*-linux-gnu
             Target|                            |s390x-*-linux-gnu

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Does it happen with a cross compiler or just a native compiler?

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

* [Bug c/103980] -Wdouble-promotion triggers on s390x when it shouldn't.
  2022-01-11 20:02 [Bug c/103980] New: -Wdouble-promotion triggers on s390x when it shouldn't rmaguire314 at gmail dot com
  2022-01-11 20:15 ` [Bug c/103980] " pinskia at gcc dot gnu.org
@ 2022-01-11 20:54 ` joseph at codesourcery dot com
  2022-01-11 21:06 ` pinskia at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: joseph at codesourcery dot com @ 2022-01-11 20:54 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from joseph at codesourcery dot com <joseph at codesourcery dot com> ---
If it's specific to s390, I wonder if it's something to do with excess 
precision being enabled by -std=c89 (see commit 
a5dd6b69fcbe74c02d4821ac2daf2b8c9f819f6e regarding s390 excess precision, 
but even if that means it doesn't appear by default with newer GCC on 
s390, if it's an excess precision issue I'd expect it to appear also with 
x86 -mfpmath=387).

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

* [Bug c/103980] -Wdouble-promotion triggers on s390x when it shouldn't.
  2022-01-11 20:02 [Bug c/103980] New: -Wdouble-promotion triggers on s390x when it shouldn't rmaguire314 at gmail dot com
  2022-01-11 20:15 ` [Bug c/103980] " pinskia at gcc dot gnu.org
  2022-01-11 20:54 ` joseph at codesourcery dot com
@ 2022-01-11 21:06 ` pinskia at gcc dot gnu.org
  2022-01-11 21:33 ` joseph at codesourcery dot com
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-11 21:06 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to joseph@codesourcery.com from comment #2)
> If it's specific to s390, I wonder if it's something to do with excess 
> precision being enabled by -std=c89 (see commit 
> a5dd6b69fcbe74c02d4821ac2daf2b8c9f819f6e regarding s390 excess precision, 
> but even if that means it doesn't appear by default with newer GCC on 
> s390, if it's an excess precision issue I'd expect it to appear also with 
> x86 -mfpmath=387).

Right, I tried it on x86 with "-m32 -Wdouble-promotion -std=c89 -mfpmath=387
-fexcess-precision=standard -mno-sse" and could not reproduce the failure which
is why I asked it was a native or cross compiler, trying to figure out if there
is a bug miscompiling the front-end or otherwise.

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

* [Bug c/103980] -Wdouble-promotion triggers on s390x when it shouldn't.
  2022-01-11 20:02 [Bug c/103980] New: -Wdouble-promotion triggers on s390x when it shouldn't rmaguire314 at gmail dot com
                   ` (2 preceding siblings ...)
  2022-01-11 21:06 ` pinskia at gcc dot gnu.org
@ 2022-01-11 21:33 ` joseph at codesourcery dot com
  2022-01-11 22:22 ` rmaguire314 at gmail dot com
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: joseph at codesourcery dot com @ 2022-01-11 21:33 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from joseph at codesourcery dot com <joseph at codesourcery dot com> ---
Possible the way x86 excess precision promotes to long double means this 
is only an issue for s390 excess precision (if it is an excess precision 
issue).

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

* [Bug c/103980] -Wdouble-promotion triggers on s390x when it shouldn't.
  2022-01-11 20:02 [Bug c/103980] New: -Wdouble-promotion triggers on s390x when it shouldn't rmaguire314 at gmail dot com
                   ` (3 preceding siblings ...)
  2022-01-11 21:33 ` joseph at codesourcery dot com
@ 2022-01-11 22:22 ` rmaguire314 at gmail dot com
  2022-01-12  2:04 ` [Bug target/103980] " pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rmaguire314 at gmail dot com @ 2022-01-11 22:22 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Ryan <rmaguire314 at gmail dot com> ---
(In reply to Andrew Pinski from comment #1)
> Does it happen with a cross compiler or just a native compiler?

Not sure what you mean by that.
I'm emulating s390x on a Debian 11 amd64 machine via debootstrap:

sudo debootstrap --arch=s390x stable S390X

I chroot into it:

sudo chroot S390X/

I then install the following from Debian's repository:

apt-get install gcc git sudo

I'm writing an implementation of libm for fun.
Tried building the library with gcc with a bunch of flags to check for errors:

STDVER="-std=c89"
...
ExtraArgs=""
...
CArgs1="-pedantic -Wall -Wextra -Wpedantic -Wmissing-field-initializers"
CArgs2="-Wconversion -Wmissing-prototypes -Wmissing-declarations"
CArgs3="-Winit-self -Wnull-dereference -Wwrite-strings -Wdouble-promotion"
CArgs4="-Wfloat-conversion -Wstrict-prototypes -Wold-style-definition"
CArgs5="-I../ -DNDEBUG -g -fPIC -O3 -flto -c"
CompilerArgs="$STDVER $ExtraArgs $CArgs1 $CArgs2 $CArgs3 $CArgs4 $CArgs5"

The library builds but throws -Wdouble-promotion every time a float (single
precision) comparison is made. Removing the -std=c89 flag removes this warning,
which is strange. No issues on any other architectures. I've tried mips,
mipsel, mips64el, i386, arm64, armel, armhf, and amd64. All Debian via
debootstrap. I've also tried using LLVM's clang, pcc, and tcc (again, from
Debian's repositories, and when available since those compilers don't support
as many architectures) using the same arguments above. No warnings or errors on
any of them.

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

* [Bug target/103980] -Wdouble-promotion triggers on s390x when it shouldn't.
  2022-01-11 20:02 [Bug c/103980] New: -Wdouble-promotion triggers on s390x when it shouldn't rmaguire314 at gmail dot com
                   ` (4 preceding siblings ...)
  2022-01-11 22:22 ` rmaguire314 at gmail dot com
@ 2022-01-12  2:04 ` pinskia at gcc dot gnu.org
  2022-01-12  2:06 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-12  2:04 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
               Host|s390x-*-linux-gnu           |
              Build|s390x-*-linux-gnu           |
          Component|c                           |target

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
g:638108bd6748d7c38dceac491a62c6ce5355850d
g:a5dd6b69fcbe74c02d4821ac2daf2b8c9f819f6e 

Are the two important ones to read.

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

* [Bug target/103980] -Wdouble-promotion triggers on s390x when it shouldn't.
  2022-01-11 20:02 [Bug c/103980] New: -Wdouble-promotion triggers on s390x when it shouldn't rmaguire314 at gmail dot com
                   ` (5 preceding siblings ...)
  2022-01-12  2:04 ` [Bug target/103980] " pinskia at gcc dot gnu.org
@ 2022-01-12  2:06 ` pinskia at gcc dot gnu.org
  2022-01-12 17:44 ` rmaguire314 at gmail dot com
  2022-01-12 18:12 ` pinskia at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-12  2:06 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
It might be the case Wdouble-promotion is just useless on s390 if you configure
your compiler with --enable-s390-excess-float-precision which was only added
for GCC11, so basically between GCC 7 and GCC 10.x, the default was to promote
all float to double for s390.

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

* [Bug target/103980] -Wdouble-promotion triggers on s390x when it shouldn't.
  2022-01-11 20:02 [Bug c/103980] New: -Wdouble-promotion triggers on s390x when it shouldn't rmaguire314 at gmail dot com
                   ` (6 preceding siblings ...)
  2022-01-12  2:06 ` pinskia at gcc dot gnu.org
@ 2022-01-12 17:44 ` rmaguire314 at gmail dot com
  2022-01-12 18:12 ` pinskia at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: rmaguire314 at gmail dot com @ 2022-01-12 17:44 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Ryan <rmaguire314 at gmail dot com> ---
(In reply to Andrew Pinski from comment #7)
> It might be the case Wdouble-promotion is just useless on s390 if you
> configure your compiler with --enable-s390-excess-float-precision which was
> only added for GCC11, so basically between GCC 7 and GCC 10.x, the default
> was to promote all float to double for s390.

It still seems odd that the warning is only produced when the -std flag is set,
and only when comparisons are made.

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

* [Bug target/103980] -Wdouble-promotion triggers on s390x when it shouldn't.
  2022-01-11 20:02 [Bug c/103980] New: -Wdouble-promotion triggers on s390x when it shouldn't rmaguire314 at gmail dot com
                   ` (7 preceding siblings ...)
  2022-01-12 17:44 ` rmaguire314 at gmail dot com
@ 2022-01-12 18:12 ` pinskia at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-01-12 18:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Ryan from comment #8)
> (In reply to Andrew Pinski from comment #7)
> > It might be the case Wdouble-promotion is just useless on s390 if you
> > configure your compiler with --enable-s390-excess-float-precision which was
> > only added for GCC11, so basically between GCC 7 and GCC 10.x, the default
> > was to promote all float to double for s390.
> 
> It still seems odd that the warning is only produced when the -std flag is
> set, and only when comparisons are made.

-std enables -fexcess-precision=standard option.

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

end of thread, other threads:[~2022-01-12 18:12 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-11 20:02 [Bug c/103980] New: -Wdouble-promotion triggers on s390x when it shouldn't rmaguire314 at gmail dot com
2022-01-11 20:15 ` [Bug c/103980] " pinskia at gcc dot gnu.org
2022-01-11 20:54 ` joseph at codesourcery dot com
2022-01-11 21:06 ` pinskia at gcc dot gnu.org
2022-01-11 21:33 ` joseph at codesourcery dot com
2022-01-11 22:22 ` rmaguire314 at gmail dot com
2022-01-12  2:04 ` [Bug target/103980] " pinskia at gcc dot gnu.org
2022-01-12  2:06 ` pinskia at gcc dot gnu.org
2022-01-12 17:44 ` rmaguire314 at gmail dot com
2022-01-12 18:12 ` pinskia 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).