public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/107466] New: [12 Regression] invalid -Wnarrowing error
@ 2022-10-30 18:42 littlefox+gcc-bugzilla@lf-net.org
  2022-10-30 18:50 ` [Bug c++/107466] [12/13 Regression] invalid -Wnarrowing error with std::subtract_with_carry_engine pinskia at gcc dot gnu.org
                   ` (15 more replies)
  0 siblings, 16 replies; 17+ messages in thread
From: littlefox+gcc-bugzilla@lf-net.org @ 2022-10-30 18:42 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 107466
           Summary: [12 Regression] invalid -Wnarrowing error
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: littlefox+gcc-bugzilla@lf-net.org
  Target Milestone: ---

Created attachment 53797
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53797&action=edit
Code triggering the error

Hi,

the attached code (and Godbolt[1]) fails in gcc 12+ with an -Wnarrowing error
in a stdlibc++ template instantiated with an uint16_t and apparently trying to
work with a 2^31:

/opt/compiler-explorer/gcc-12.2.0/include/c++/12.2.0/bits/random.tcc:545:9:
error: narrowing conversion of '2147483563' from 'unsigned int' to 'short
unsigned int' [-Wnarrowing]
  545 |         __lcg(__value == 0u ? default_seed : __value);

The code works fine in 11.3 and clang (14) and since it also works in clang
using libstdc++ 12.2, this error is probably in gcc itself and not in
libstdc++.

Tested this on my machine (debian testing), where it broke after a some system
updates where installed - including a gcc update. Then tested this in Godbolt
to check compiler versions and other configurations and asked in
libera.chat/#c++ for others to verify if my code makes sense - which it seems
to do.

Best, Mara

[1] Godbolt link: https://godbolt.org/z/sj18Mv5j9

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

end of thread, other threads:[~2024-02-08 21:42 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-30 18:42 [Bug c++/107466] New: [12 Regression] invalid -Wnarrowing error littlefox+gcc-bugzilla@lf-net.org
2022-10-30 18:50 ` [Bug c++/107466] [12/13 Regression] invalid -Wnarrowing error with std::subtract_with_carry_engine pinskia at gcc dot gnu.org
2022-10-30 20:40 ` redi at gcc dot gnu.org
2022-10-31 17:40 ` littlefox+gcc-bugzilla@lf-net.org
2022-11-04 20:39 ` [Bug libstdc++/107466] " redi at gcc dot gnu.org
2022-11-05 10:26 ` rguenth at gcc dot gnu.org
2022-11-25  9:38 ` redi at gcc dot gnu.org
2022-11-28 15:19 ` cvs-commit at gcc dot gnu.org
2023-04-27 11:42 ` [Bug libstdc++/107466] [12 " rguenth at gcc dot gnu.org
2023-04-27 11:42 ` rguenth at gcc dot gnu.org
2023-04-27 14:43 ` cvs-commit at gcc dot gnu.org
2023-04-27 14:44 ` redi at gcc dot gnu.org
2024-01-11 13:34 ` redi at gcc dot gnu.org
2024-01-13  0:14 ` cvs-commit at gcc dot gnu.org
2024-02-08 15:51 ` cvs-commit at gcc dot gnu.org
2024-02-08 21:28 ` cvs-commit at gcc dot gnu.org
2024-02-08 21:42 ` 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).