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

Eric Gallager <egallager at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |egallager at gcc dot gnu.org
         Resolution|---                         |DUPLICATE

--- Comment #1 from Eric Gallager <egallager at gcc dot gnu.org> ---
(In reply to Ian Mallett from comment #0)
> Minimal example (compile GCC >= ~6.1 with -Wsign-conversion):
> 
>     #include <cstdlib>
>     bool f(size_t const xy[2], int z) {
>       return xy[0] + xy[1] < static_cast<size_t>(z);
>     }
> 
> Produces an erroneous warning:
> 
>     <source>: In function 'bool f(const size_t*, int)':
>     <source>:3:25: warning: conversion to 'long unsigned int' from 'int' may
> change the sign of the result [-Wsign-conversion]
>       return xy[0] + xy[1] < static_cast<size_t>(z);
>                              ^~~~~~~~~~~~~~~~~~~~~~
>     Compiler exited with result code 0
> 
> Taking the const out, using unsigned, or passing x and y separately rather
> than as an array resolves the warning.  Doesn't occur on Clang, MSVC, or
> earlier GCC.
> 
> May be related to bug 66170.

I closed that one as a dup of bug 60342 so I'm gonna do likewise with this one,
too. (Just like those two the warning is gone here with gcc8, too)

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

Reply via email to