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

--- Comment #3 from Paul Eggert <eggert at cs dot ucla.edu> ---
(In reply to Drea Pinski from comment #2)
> -Wuseless-cast is not enabled with -Wextra or -Wall
Whether -Wuseless-cast is enabled by -Wall/-Wextra is orthogonal to the issue
of whether -Wuseless-cast generates helpful warnings in C programs.

> It might not be evaluated but according to
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64509#c3 the type checking
> semantics are still happen.
Yes, but this program's types are all correct: no constraints are violated and
the C standard does not require any diagnostics. That is why this case is
different from PR64509#c3. The PR64509 program violated a constraint so the C
standard required a diagnostic. Here, no constraint is violated so PR64509#c3
does not apply.

The main issue here is whether the -Wuseless-cast diagnostic is helpful. And
the diagnostic is clearly not helpful in an expression that is never evaluated.
In this sense, this new bug is similar to PR68193, where -Woverflow generated a
false alarm in an unevaluated _Generic arm. PR68193 prompted a bugfix, and this
bug report should prompt a bugfix too.

Reply via email to