public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/112498] New: std::is_convertible<float, _Float16>::value returns false
@ 2023-11-12 22:28 josopait at goopax dot com
2023-11-12 22:35 ` [Bug c++/112498] " pinskia at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: josopait at goopax dot com @ 2023-11-12 22:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112498
Bug ID: 112498
Summary: std::is_convertible<float, _Float16>::value returns
false
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: josopait at goopax dot com
Target Milestone: ---
If I am not mistaken, this should succeed:
#include <type_traits>
int main()
{
static_assert(std::is_convertible<double, float>::value); // ok
static_assert(std::is_convertible<float, _Float16>::value); // fails
}
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/112498] std::is_convertible<float, _Float16>::value returns false
2023-11-12 22:28 [Bug libstdc++/112498] New: std::is_convertible<float, _Float16>::value returns false josopait at goopax dot com
@ 2023-11-12 22:35 ` pinskia at gcc dot gnu.org
2023-11-12 23:56 ` josopait at goopax dot com
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-11-12 22:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112498
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |INVALID
Status|UNCONFIRMED |RESOLVED
Component|libstdc++ |c++
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=111842
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
No.
```
_Float16 f(float a)
{
return a;
}
```
is invalid C++23 code.
<source>:3:10: warning: converting to '_Float16' from 'float' with greater
conversion rank
Maybe we should add this to the FAQ because we get a question about implicit
conversion from _Float16 to float a few times now.
See
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p1467r4.html#implicit
Which is the C++ paper which adds the extended floating point types and GCC
implements it full. Just as an extension allows the conversion (with a warning)
but since we cannot have different behavior for sfinae and concepts with
-pedantic/-pedantic-errors std::is_convertible needs to return false.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/112498] std::is_convertible<float, _Float16>::value returns false
2023-11-12 22:28 [Bug libstdc++/112498] New: std::is_convertible<float, _Float16>::value returns false josopait at goopax dot com
2023-11-12 22:35 ` [Bug c++/112498] " pinskia at gcc dot gnu.org
@ 2023-11-12 23:56 ` josopait at goopax dot com
2023-11-13 10:10 ` redi at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: josopait at goopax dot com @ 2023-11-12 23:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112498
--- Comment #2 from Ingo Josopait <josopait at goopax dot com> ---
Yes, you are right. It is confusing, though. Maybe the warning message should
mention that it is actually invalid code. It looked more like a suggestion to
me.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/112498] std::is_convertible<float, _Float16>::value returns false
2023-11-12 22:28 [Bug libstdc++/112498] New: std::is_convertible<float, _Float16>::value returns false josopait at goopax dot com
2023-11-12 22:35 ` [Bug c++/112498] " pinskia at gcc dot gnu.org
2023-11-12 23:56 ` josopait at goopax dot com
@ 2023-11-13 10:10 ` redi at gcc dot gnu.org
2023-11-14 9:55 ` cvs-commit at gcc dot gnu.org
2023-11-14 10:32 ` redi at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2023-11-13 10:10 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112498
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Maybe we could add "is not allowed in ISO C++" or similar to the warning.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/112498] std::is_convertible<float, _Float16>::value returns false
2023-11-12 22:28 [Bug libstdc++/112498] New: std::is_convertible<float, _Float16>::value returns false josopait at goopax dot com
` (2 preceding siblings ...)
2023-11-13 10:10 ` redi at gcc dot gnu.org
@ 2023-11-14 9:55 ` cvs-commit at gcc dot gnu.org
2023-11-14 10:32 ` redi at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-11-14 9:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112498
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>:
https://gcc.gnu.org/g:69d69865a792a93cce2905617c53913769d0f260
commit r14-5436-g69d69865a792a93cce2905617c53913769d0f260
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Mon Nov 13 12:03:31 2023 +0000
c++: Link extended FP conversion pedwarns to -Wnarrowing [PR111842]
Several users have been confused by the status of these warnings,
which can be misunderstood as "this might not be what you want",
rather than diagnostics required by the C++ standard. Add the text "ISO
C++ does not allow" to make this clear.
Also link them to -Wnarrowing so that they can be disabled or promoted
to errors independently of other pedwarns.
PR c++/111842
PR c++/112498
gcc/cp/ChangeLog:
* call.cc (convert_like_internal): Use OPT_Wnarrowing for
pedwarns about illformed conversions involving extended
floating-point types. Clarify that ISO C++ requires these
diagnostics.
gcc/testsuite/ChangeLog:
* g++.dg/cpp23/ext-floating16.C: New test.
* g++.dg/cpp23/ext-floating17.C: New test.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/112498] std::is_convertible<float, _Float16>::value returns false
2023-11-12 22:28 [Bug libstdc++/112498] New: std::is_convertible<float, _Float16>::value returns false josopait at goopax dot com
` (3 preceding siblings ...)
2023-11-14 9:55 ` cvs-commit at gcc dot gnu.org
@ 2023-11-14 10:32 ` redi at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2023-11-14 10:32 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112498
--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #3)
> Maybe we could add "is not allowed in ISO C++" or similar to the warning.
This has been done for GCC 14:
fp.cc:2:20: warning: ISO C++ does not allow converting to 'std::float16_t' {aka
'_Float16'} from 'float' with greater conversion rank [-Wnarrowing]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-11-14 10:32 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-12 22:28 [Bug libstdc++/112498] New: std::is_convertible<float, _Float16>::value returns false josopait at goopax dot com
2023-11-12 22:35 ` [Bug c++/112498] " pinskia at gcc dot gnu.org
2023-11-12 23:56 ` josopait at goopax dot com
2023-11-13 10:10 ` redi at gcc dot gnu.org
2023-11-14 9:55 ` cvs-commit at gcc dot gnu.org
2023-11-14 10:32 ` redi 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).