public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug testsuite/111883] New: Wstringop-overflow-6.C FAILs with -std=c++26
@ 2023-10-19 17:32 mpolacek at gcc dot gnu.org
  2023-10-19 20:15 ` [Bug testsuite/111883] " redi at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2023-10-19 17:32 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 111883
           Summary: Wstringop-overflow-6.C FAILs with -std=c++26
           Product: gcc
           Version: 13.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: testsuite
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mpolacek at gcc dot gnu.org
  Target Milestone: ---

FAIL: g++.dg/warn/Wstringop-overflow-6.C  -std=gnu++26 (test for excess errors)

the excess warning is:

$ xg++ -c Wstringop-overflow-6.C  -std=gnu++26 -O2 -Wall -Wsystem-headers 
In file included from
/home/mpolacek/x/trunk/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/basic_string.h:51,
                 from
/home/mpolacek/x/trunk/x86_64-pc-linux-gnu/libstdc++-v3/include/string:54,
                 from
/home/mpolacek/x/trunk/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/locale_classes.h:40,
                 from
/home/mpolacek/x/trunk/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/ios_base.h:41,
                 from
/home/mpolacek/x/trunk/x86_64-pc-linux-gnu/libstdc++-v3/include/ios:44,
                 from
/home/mpolacek/x/trunk/x86_64-pc-linux-gnu/libstdc++-v3/include/ostream:40,
                 from
/home/mpolacek/x/trunk/x86_64-pc-linux-gnu/libstdc++-v3/include/iostream:41,
                 from Wstringop-overflow-6.C:6:
/home/mpolacek/x/trunk/x86_64-pc-linux-gnu/libstdc++-v3/include/charconv: In
function ‘std::from_chars_result std::from_chars(const char*, const char*,
_Float16&, chars_format)’:
/home/mpolacek/x/trunk/x86_64-pc-linux-gnu/libstdc++-v3/include/charconv:687:17:
warning: converting to ‘_Float16’ from ‘float’ with greater conversion rank
  687 |       __value = __val;
      |                 ^~~~~
/home/mpolacek/x/trunk/x86_64-pc-linux-gnu/libstdc++-v3/include/charconv: In
function ‘std::from_chars_result std::from_chars(const char*, const char*,
__gnu_cxx::__bfloat16_t&, chars_format)’:
/home/mpolacek/x/trunk/x86_64-pc-linux-gnu/libstdc++-v3/include/charconv:763:17:
warning: converting to ‘__gnu_cxx::__bfloat16_t’ {aka ‘__bf16’} from ‘float’
with greater conversion rank
  763 |       __value = __val;
      |                 ^~~~~

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

* [Bug testsuite/111883] Wstringop-overflow-6.C FAILs with -std=c++26
  2023-10-19 17:32 [Bug testsuite/111883] New: Wstringop-overflow-6.C FAILs with -std=c++26 mpolacek at gcc dot gnu.org
@ 2023-10-19 20:15 ` redi at gcc dot gnu.org
  2023-10-19 20:29 ` jakub at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2023-10-19 20:15 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
I think Jakub wrote that code, but it looks like we just want the explicit
casts. I can add those.

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

* [Bug testsuite/111883] Wstringop-overflow-6.C FAILs with -std=c++26
  2023-10-19 17:32 [Bug testsuite/111883] New: Wstringop-overflow-6.C FAILs with -std=c++26 mpolacek at gcc dot gnu.org
  2023-10-19 20:15 ` [Bug testsuite/111883] " redi at gcc dot gnu.org
@ 2023-10-19 20:29 ` jakub at gcc dot gnu.org
  2023-10-19 20:41 ` mpolacek at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-10-19 20:29 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Why doesn't it fail with -std=c++23 though?  Was there some C++26 change I'm
not aware of?
In the to_chars cases, we already use float(__value) casts in the
_Float16/__bfloat16_t cases (but others too), so I think we just want to add
explicit casts also to all the from_chars
      __value = __val;
lines (or at least the _Float16/__bfloat16_t cases).

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

* [Bug testsuite/111883] Wstringop-overflow-6.C FAILs with -std=c++26
  2023-10-19 17:32 [Bug testsuite/111883] New: Wstringop-overflow-6.C FAILs with -std=c++26 mpolacek at gcc dot gnu.org
  2023-10-19 20:15 ` [Bug testsuite/111883] " redi at gcc dot gnu.org
  2023-10-19 20:29 ` jakub at gcc dot gnu.org
@ 2023-10-19 20:41 ` mpolacek at gcc dot gnu.org
  2023-10-20 11:27 ` jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2023-10-19 20:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Did you mean like the following?  I have no idea if that's correct but is
suppresses the warnings I see.

In C++23 I don't see the code in the .ii file at all, so it doesn't warn.

--- a/libstdc++-v3/include/std/charconv
+++ b/libstdc++-v3/include/std/charconv
@@ -684,7 +684,7 @@ namespace __detail
     from_chars_result __res
       = __from_chars_float16_t(__first, __last, __val, __fmt);
     if (__res.ec == errc{})
-      __value = __val;
+      __value = _Float16(__val);
     return __res;
   }
 #endif
@@ -697,7 +697,7 @@ namespace __detail
     float __val;
     from_chars_result __res = from_chars(__first, __last, __val, __fmt);
     if (__res.ec == errc{})
-      __value = __val;
+      __value = _Float32(__val);
     return __res;
   }
 #endif
@@ -710,7 +710,7 @@ namespace __detail
     double __val;
     from_chars_result __res = from_chars(__first, __last, __val, __fmt);
     if (__res.ec == errc{})
-      __value = __val;
+      __value = _Float64(__val);
     return __res;
   }
 #endif
@@ -723,7 +723,7 @@ namespace __detail
     long double __val;
     from_chars_result __res = from_chars(__first, __last, __val, __fmt);
     if (__res.ec == errc{})
-      __value = __val;
+      __value = _Float128(__val);
     return __res;
   }
 #elif defined(__STDCPP_FLOAT128_T__) && defined(_GLIBCXX_HAVE_FLOAT128_MATH)
@@ -739,7 +739,7 @@ namespace __detail
     __extension__ __ieee128 __val;
     from_chars_result __res = from_chars(__first, __last, __val, __fmt);
     if (__res.ec == errc{})
-      __value = __val;
+      __value = _Float128(__val);
     return __res;
   }
 #else
@@ -760,7 +760,7 @@ namespace __detail
     from_chars_result __res
       = __from_chars_bfloat16_t(__first, __last, __val, __fmt);
     if (__res.ec == errc{})
-      __value = __val;
+      __value = __gnu_cxx::__bfloat16_t(__val);
     return __res;
   }
 #endif

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

* [Bug testsuite/111883] Wstringop-overflow-6.C FAILs with -std=c++26
  2023-10-19 17:32 [Bug testsuite/111883] New: Wstringop-overflow-6.C FAILs with -std=c++26 mpolacek at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2023-10-19 20:41 ` mpolacek at gcc dot gnu.org
@ 2023-10-20 11:27 ` jakub at gcc dot gnu.org
  2023-10-20 12:04 ` redi at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-10-20 11:27 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Yeah, that is what I meant.  Note, I do see the from_chars inlines even with
-std=c++23
in preprocessed dump when including <charconv>, the difference is in
#if __cplusplus > 202302L
# include <charconv>
#endif
in bits/basic_string.h (and the trigger is -Wsystem-headers).

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

* [Bug testsuite/111883] Wstringop-overflow-6.C FAILs with -std=c++26
  2023-10-19 17:32 [Bug testsuite/111883] New: Wstringop-overflow-6.C FAILs with -std=c++26 mpolacek at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2023-10-20 11:27 ` jakub at gcc dot gnu.org
@ 2023-10-20 12:04 ` redi at gcc dot gnu.org
  2023-10-20 13:13 ` mpolacek at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2023-10-20 12:04 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2023-10-20

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Ah yes, std::to_string(float) needs to use std::to_chars in C++26, so includes
<charconv>.

The patch in comment 3 looks correct, feel free to push it if it passes tests.

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

* [Bug testsuite/111883] Wstringop-overflow-6.C FAILs with -std=c++26
  2023-10-19 17:32 [Bug testsuite/111883] New: Wstringop-overflow-6.C FAILs with -std=c++26 mpolacek at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2023-10-20 12:04 ` redi at gcc dot gnu.org
@ 2023-10-20 13:13 ` mpolacek at gcc dot gnu.org
  2023-10-20 16:36 ` cvs-commit at gcc dot gnu.org
  2023-10-20 16:37 ` mpolacek at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2023-10-20 13:13 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |mpolacek at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

--- Comment #6 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Thanks, I'll do a full test cycle.

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

* [Bug testsuite/111883] Wstringop-overflow-6.C FAILs with -std=c++26
  2023-10-19 17:32 [Bug testsuite/111883] New: Wstringop-overflow-6.C FAILs with -std=c++26 mpolacek at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2023-10-20 13:13 ` mpolacek at gcc dot gnu.org
@ 2023-10-20 16:36 ` cvs-commit at gcc dot gnu.org
  2023-10-20 16:37 ` mpolacek at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-10-20 16:36 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:

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

commit r14-4799-g1d9263f292c3efc4e37c3a88117388e86d19b954
Author: Marek Polacek <polacek@redhat.com>
Date:   Thu Oct 19 17:48:44 2023 -0400

    libstdc++: add casts to from_chars in <charconv> [PR111883]

    This fixes

    .../charconv: In function 'std::from_chars_result std::from_chars(const
char*, const char*, _Float16&, chars_format)':
    .../charconv:687:17: warning: converting to '_Float16' from 'float' with
greater conversion rank
      687 |       __value = __val;
          |                 ^~~~~
    .../charconv: In function 'std::from_chars_result std::from_chars(const
char*, const char*, __gnu_cxx::__bfloat16_t&, chars_format)':
    .../charconv:763:17: warning: converting to '__gnu_cxx::__bfloat16_t' {aka
'__bf16'} from 'float' with greater conversion rank
      763 |       __value = __val;
          |                 ^~~~~

    which was breaking a test:

    FAIL: g++.dg/warn/Wstringop-overflow-6.C  -std=gnu++26 (test for excess
errors)

            PR testsuite/111883

    libstdc++-v3/ChangeLog:

            * include/std/charconv (from_chars): Add explicit casts.

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

* [Bug testsuite/111883] Wstringop-overflow-6.C FAILs with -std=c++26
  2023-10-19 17:32 [Bug testsuite/111883] New: Wstringop-overflow-6.C FAILs with -std=c++26 mpolacek at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2023-10-20 16:36 ` cvs-commit at gcc dot gnu.org
@ 2023-10-20 16:37 ` mpolacek at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2023-10-20 16:37 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

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

--- Comment #8 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Should be fixed now.

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

end of thread, other threads:[~2023-10-20 16:37 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-19 17:32 [Bug testsuite/111883] New: Wstringop-overflow-6.C FAILs with -std=c++26 mpolacek at gcc dot gnu.org
2023-10-19 20:15 ` [Bug testsuite/111883] " redi at gcc dot gnu.org
2023-10-19 20:29 ` jakub at gcc dot gnu.org
2023-10-19 20:41 ` mpolacek at gcc dot gnu.org
2023-10-20 11:27 ` jakub at gcc dot gnu.org
2023-10-20 12:04 ` redi at gcc dot gnu.org
2023-10-20 13:13 ` mpolacek at gcc dot gnu.org
2023-10-20 16:36 ` cvs-commit at gcc dot gnu.org
2023-10-20 16:37 ` mpolacek 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).