public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/114237] New: GCC emits no narrowing conversion warning when call is made indirectly through std::invoke
@ 2024-03-05 12:34 jlame646 at gmail dot com
  2024-03-05 14:28 ` [Bug c++/114237] " redi at gcc dot gnu.org
  2024-03-05 14:29 ` redi at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: jlame646 at gmail dot com @ 2024-03-05 12:34 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 114237
           Summary: GCC emits no narrowing conversion warning when call is
                    made indirectly through std::invoke
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jlame646 at gmail dot com
  Target Milestone: ---

Gcc emits no narrowing conversion warning for the following program. Only msvc
emits the warning. https://godbolt.org/z/EPKv9fdWr

```
void expectsInt32(int32_t) {
    /* … */
}

template<typename Func, typename Arg>
void call(Func func, Arg arg) {
    std::invoke(func, arg); // arg is size_t, potentially causing narrowing
conversion
}

int main() {
    size_t largeNumber = 4294967295; // Maximum value for uint32_t
    call(expectsInt32, largeNumber); // Compiles without warning in GCC/Clang
with -Wconversion
    return 0;
}
```
Even with -Wconversion and other flags as shown in the demo, no warning is
emitted by gcc and clang.

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

* [Bug c++/114237] GCC emits no narrowing conversion warning when call is made indirectly through std::invoke
  2024-03-05 12:34 [Bug c++/114237] New: GCC emits no narrowing conversion warning when call is made indirectly through std::invoke jlame646 at gmail dot com
@ 2024-03-05 14:28 ` redi at gcc dot gnu.org
  2024-03-05 14:29 ` redi at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2024-03-05 14:28 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The conversion happens in a system header, so is suppressed without
-Wsystem-headers

There are existing bug reports about -Wconversion warnings being suppressed in
system headers.

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

* [Bug c++/114237] GCC emits no narrowing conversion warning when call is made indirectly through std::invoke
  2024-03-05 12:34 [Bug c++/114237] New: GCC emits no narrowing conversion warning when call is made indirectly through std::invoke jlame646 at gmail dot com
  2024-03-05 14:28 ` [Bug c++/114237] " redi at gcc dot gnu.org
@ 2024-03-05 14:29 ` redi at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2024-03-05 14:29 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
dup

*** This bug has been marked as a duplicate of bug 43167 ***

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

end of thread, other threads:[~2024-03-05 14:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-05 12:34 [Bug c++/114237] New: GCC emits no narrowing conversion warning when call is made indirectly through std::invoke jlame646 at gmail dot com
2024-03-05 14:28 ` [Bug c++/114237] " redi at gcc dot gnu.org
2024-03-05 14:29 ` 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).