public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/109884] New: __builtin_Xq returns _Float128 instead of __float128
@ 2023-05-17  7:02 g.peterhoff@t-online.de
  2023-05-17  7:07 ` [Bug c++/109884] " pinskia at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: g.peterhoff@t-online.de @ 2023-05-17  7:02 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 109884
           Summary: __builtin_Xq returns _Float128 instead of __float128
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: g.peterhoff@t-online.de
  Target Milestone: ---

#include <boost/core/demangle.hpp>
#include <quadmath.h>
#include <typeinfo>
#include <iostream>
#include <string>

template <typename Type>
inline std::string nameof()
{
 return boost::core::demangle(typeid(Type).name());
}

int main()
{
 std::cout << nameof<decltype(HUGE_VALQ)>() << std::endl;
 std::cout << nameof<decltype(__builtin_nansq(""))>() << std::endl;
 std::cout << nameof<decltype(__builtin_nanq(""))>() << std::endl;
}

compiled with 13 returns the incorrect type
_Float128
_Float128
_Float128
with 12 or older gives the correct type
__float128
__float128
__float128

regards
Gero

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

* [Bug c++/109884] __builtin_Xq returns _Float128 instead of __float128
  2023-05-17  7:02 [Bug c++/109884] New: __builtin_Xq returns _Float128 instead of __float128 g.peterhoff@t-online.de
@ 2023-05-17  7:07 ` pinskia at gcc dot gnu.org
  2023-05-17  7:09 ` pinskia at gcc dot gnu.org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-05-17  7:07 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I think this is expected behavior now.

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

* [Bug c++/109884] __builtin_Xq returns _Float128 instead of __float128
  2023-05-17  7:02 [Bug c++/109884] New: __builtin_Xq returns _Float128 instead of __float128 g.peterhoff@t-online.de
  2023-05-17  7:07 ` [Bug c++/109884] " pinskia at gcc dot gnu.org
@ 2023-05-17  7:09 ` pinskia at gcc dot gnu.org
  2023-05-17  7:17 ` g.peterhoff@t-online.de
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-05-17  7:09 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
_Float128 is the standard specified way of defining these types in c++23 IIRC.

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

* [Bug c++/109884] __builtin_Xq returns _Float128 instead of __float128
  2023-05-17  7:02 [Bug c++/109884] New: __builtin_Xq returns _Float128 instead of __float128 g.peterhoff@t-online.de
  2023-05-17  7:07 ` [Bug c++/109884] " pinskia at gcc dot gnu.org
  2023-05-17  7:09 ` pinskia at gcc dot gnu.org
@ 2023-05-17  7:17 ` g.peterhoff@t-online.de
  2023-05-17  7:19 ` pinskia at gcc dot gnu.org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: g.peterhoff@t-online.de @ 2023-05-17  7:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from g.peterhoff@t-online.de ---
But these are different types (even if they are mathematically/behaviorally
equivalent)
std::is_same_v<std::float128_t, __float128> --> false

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

* [Bug c++/109884] __builtin_Xq returns _Float128 instead of __float128
  2023-05-17  7:02 [Bug c++/109884] New: __builtin_Xq returns _Float128 instead of __float128 g.peterhoff@t-online.de
                   ` (2 preceding siblings ...)
  2023-05-17  7:17 ` g.peterhoff@t-online.de
@ 2023-05-17  7:19 ` pinskia at gcc dot gnu.org
  2023-05-17  7:20 ` redi at gcc dot gnu.org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-05-17  7:19 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
OK. And?
Q specifies the _Float128 type now.

I don't think we had any abi guarantees on the builtins nor on the q literals.

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

* [Bug c++/109884] __builtin_Xq returns _Float128 instead of __float128
  2023-05-17  7:02 [Bug c++/109884] New: __builtin_Xq returns _Float128 instead of __float128 g.peterhoff@t-online.de
                   ` (3 preceding siblings ...)
  2023-05-17  7:19 ` pinskia at gcc dot gnu.org
@ 2023-05-17  7:20 ` redi at gcc dot gnu.org
  2023-05-17  8:34 ` jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2023-05-17  7:20 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This changed with r13-2887 when adding _Float128 to C++

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

* [Bug c++/109884] __builtin_Xq returns _Float128 instead of __float128
  2023-05-17  7:02 [Bug c++/109884] New: __builtin_Xq returns _Float128 instead of __float128 g.peterhoff@t-online.de
                   ` (4 preceding siblings ...)
  2023-05-17  7:20 ` redi at gcc dot gnu.org
@ 2023-05-17  8:34 ` jakub at gcc dot gnu.org
  2023-05-17  9:02 ` jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-05-17  8:34 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Note, these builtins aren't standard builtins, but backend registered ones:
grep '"__builtin_[a-z]*q["=]' gcc/config/*/* 2>/dev/null
gcc/config/i386/i386-builtins.cc:  def_builtin_const (0, 0, "__builtin_infq",
gcc/config/i386/i386-builtins.cc:  decl = add_builtin_function
("__builtin_nanq", ftype, IX86_BUILTIN_NANQ,
gcc/config/i386/i386-builtins.cc:  decl = add_builtin_function
("__builtin_nansq", ftype, IX86_BUILTIN_NANSQ,
gcc/config/i386/i386-builtins.cc:  decl = add_builtin_function
("__builtin_fabsq", ftype, IX86_BUILTIN_FABSQ,
gcc/config/i386/i386-builtins.cc:  decl = add_builtin_function
("__builtin_copysignq", ftype,
gcc/config/ia64/ia64.cc:      decl = add_builtin_function ("__builtin_infq",
ftype,
gcc/config/ia64/ia64.cc:      decl = add_builtin_function ("__builtin_nanq",
ftype,
gcc/config/ia64/ia64.cc:      decl = add_builtin_function ("__builtin_nansq",
ftype,
gcc/config/ia64/ia64.cc:      decl = add_builtin_function ("__builtin_fabsq",
ftype,
gcc/config/ia64/ia64.cc:      decl = add_builtin_function
("__builtin_copysignq", ftype,
gcc/config/pa/pa.cc:      decl = add_builtin_function ("__builtin_fabsq",
ftype,
gcc/config/pa/pa.cc:      decl = add_builtin_function ("__builtin_copysignq",
ftype,
gcc/config/pa/pa.cc:      decl = add_builtin_function ("__builtin_infq", ftype,
gcc/config/rs6000/rs6000-c.cc:      builtin_define
("__builtin_fabsq=__builtin_fabsf128");
gcc/config/rs6000/rs6000-c.cc:      builtin_define
("__builtin_copysignq=__builtin_copysignf128");
gcc/config/rs6000/rs6000-c.cc:      builtin_define
("__builtin_nanq=__builtin_nanf128");
gcc/config/rs6000/rs6000-c.cc:      builtin_define
("__builtin_nansq=__builtin_nansf128");
gcc/config/rs6000/rs6000-c.cc:      builtin_define
("__builtin_infq=__builtin_inff128");
and have been that way before as well.  Given how they are defined on rs6000,
at least there because it is just a macro for the f128 suffixed ones it really
has to return _Float128.

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

* [Bug c++/109884] __builtin_Xq returns _Float128 instead of __float128
  2023-05-17  7:02 [Bug c++/109884] New: __builtin_Xq returns _Float128 instead of __float128 g.peterhoff@t-online.de
                   ` (5 preceding siblings ...)
  2023-05-17  8:34 ` jakub at gcc dot gnu.org
@ 2023-05-17  9:02 ` jakub at gcc dot gnu.org
  2023-05-17  9:03 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-05-17  9:02 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
     Ever confirmed|0                           |1
           Assignee|unassigned at gcc dot gnu.org      |jakub at gcc dot gnu.org
   Last reconfirmed|                            |2023-05-17

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 55098
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55098&action=edit
gcc14-pr109884.patch

Untested fix.  For ia64, I think it already uses float128t_type_node,
for rs6000 as I wrote it is more difficult because it doesn't have the
builtins but macros and in pa case, __float128 is the same as long double.

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

* [Bug c++/109884] __builtin_Xq returns _Float128 instead of __float128
  2023-05-17  7:02 [Bug c++/109884] New: __builtin_Xq returns _Float128 instead of __float128 g.peterhoff@t-online.de
                   ` (6 preceding siblings ...)
  2023-05-17  9:02 ` jakub at gcc dot gnu.org
@ 2023-05-17  9:03 ` jakub at gcc dot gnu.org
  2023-05-17 19:00 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-05-17  9:03 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #4)
> Q specifies the _Float128 type now.

No, Q suffix specifies __float128 actually.  F128 or f128 specify _Float128.

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

* [Bug c++/109884] __builtin_Xq returns _Float128 instead of __float128
  2023-05-17  7:02 [Bug c++/109884] New: __builtin_Xq returns _Float128 instead of __float128 g.peterhoff@t-online.de
                   ` (7 preceding siblings ...)
  2023-05-17  9:03 ` jakub at gcc dot gnu.org
@ 2023-05-17 19:00 ` cvs-commit at gcc dot gnu.org
  2023-05-17 19:27 ` cvs-commit at gcc dot gnu.org
  2023-05-17 19:28 ` jakub at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-05-17 19:00 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:c8da62cfc6475c4b7213b2164c2c0ec8ea6d96b6

commit r14-944-gc8da62cfc6475c4b7213b2164c2c0ec8ea6d96b6
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed May 17 20:59:54 2023 +0200

    i386: Fix up types in __builtin_{inf,huge_val,nan{,s},fabs,copysign}q
builtins [PR109884]

    When _Float128 support has been added to C++ for 13.1,  float128t_type_node
    tree has been added - in C float128_type_node and float128t_type_node is
    the same and represents both _Float128 and __float128, but in C++ they
    are distinct types which have different handling in the FEs.
    When doing that change, I mistakenly forgot to change FLOAT128 primitive
    type, which is used for the __builtin_{inf,huge_val,nan{,s},fabs,copysign}q
    builtins results and some of their arguments (and nothing else).

    The following patch fixes that.
    On ia64 we already use float128t_type_node for those builtins, pa while
    it has __float128 that type is the same as long double and so those
builtins
    have long double types and on powerpc seems we  don't have these builtins
    but instead define macros which map them to __builtin_*f128.  That will
    not work properly in C++, perhaps we should change those macros to be
    function-like and cast to __float128.

    2023-05-17  Jakub Jelinek  <jakub@redhat.com>

            PR c++/109884
            * config/i386/i386-builtin-types.def (FLOAT128): Use
            float128t_type_node rather than float128_type_node.

            * c-c++-common/pr109884.c: New test.

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

* [Bug c++/109884] __builtin_Xq returns _Float128 instead of __float128
  2023-05-17  7:02 [Bug c++/109884] New: __builtin_Xq returns _Float128 instead of __float128 g.peterhoff@t-online.de
                   ` (8 preceding siblings ...)
  2023-05-17 19:00 ` cvs-commit at gcc dot gnu.org
@ 2023-05-17 19:27 ` cvs-commit at gcc dot gnu.org
  2023-05-17 19:28 ` jakub at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-05-17 19:27 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Jakub Jelinek
<jakub@gcc.gnu.org>:

https://gcc.gnu.org/g:1ce8a5472f4fd98318b5f3575797b56b814b8ad9

commit r13-7340-g1ce8a5472f4fd98318b5f3575797b56b814b8ad9
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed May 17 20:59:54 2023 +0200

    i386: Fix up types in __builtin_{inf,huge_val,nan{,s},fabs,copysign}q
builtins [PR109884]

    When _Float128 support has been added to C++ for 13.1,  float128t_type_node
    tree has been added - in C float128_type_node and float128t_type_node is
    the same and represents both _Float128 and __float128, but in C++ they
    are distinct types which have different handling in the FEs.
    When doing that change, I mistakenly forgot to change FLOAT128 primitive
    type, which is used for the __builtin_{inf,huge_val,nan{,s},fabs,copysign}q
    builtins results and some of their arguments (and nothing else).

    The following patch fixes that.
    On ia64 we already use float128t_type_node for those builtins, pa while
    it has __float128 that type is the same as long double and so those
builtins
    have long double types and on powerpc seems we  don't have these builtins
    but instead define macros which map them to __builtin_*f128.  That will
    not work properly in C++, perhaps we should change those macros to be
    function-like and cast to __float128.

    2023-05-17  Jakub Jelinek  <jakub@redhat.com>

            PR c++/109884
            * config/i386/i386-builtin-types.def (FLOAT128): Use
            float128t_type_node rather than float128_type_node.

            * c-c++-common/pr109884.c: New test.

    (cherry picked from commit c8da62cfc6475c4b7213b2164c2c0ec8ea6d96b6)

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

* [Bug c++/109884] __builtin_Xq returns _Float128 instead of __float128
  2023-05-17  7:02 [Bug c++/109884] New: __builtin_Xq returns _Float128 instead of __float128 g.peterhoff@t-online.de
                   ` (9 preceding siblings ...)
  2023-05-17 19:27 ` cvs-commit at gcc dot gnu.org
@ 2023-05-17 19:28 ` jakub at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-05-17 19:28 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #11 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed for 13.2/14.1.

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

end of thread, other threads:[~2023-05-17 19:28 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-17  7:02 [Bug c++/109884] New: __builtin_Xq returns _Float128 instead of __float128 g.peterhoff@t-online.de
2023-05-17  7:07 ` [Bug c++/109884] " pinskia at gcc dot gnu.org
2023-05-17  7:09 ` pinskia at gcc dot gnu.org
2023-05-17  7:17 ` g.peterhoff@t-online.de
2023-05-17  7:19 ` pinskia at gcc dot gnu.org
2023-05-17  7:20 ` redi at gcc dot gnu.org
2023-05-17  8:34 ` jakub at gcc dot gnu.org
2023-05-17  9:02 ` jakub at gcc dot gnu.org
2023-05-17  9:03 ` jakub at gcc dot gnu.org
2023-05-17 19:00 ` cvs-commit at gcc dot gnu.org
2023-05-17 19:27 ` cvs-commit at gcc dot gnu.org
2023-05-17 19:28 ` jakub 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).