[Bug c/68193] _Generic -Woverflow false alarm

2023-11-03 Thread uecker at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68193

uecker at gcc dot gnu.org changed:

   What|Removed |Added

 Resolution|--- |FIXED
 CC||uecker at gcc dot gnu.org
  Known to fail||4.9.0
   Target Milestone|--- |14.0
 Status|NEW |RESOLVED

--- Comment #9 from uecker at gcc dot gnu.org ---
Fixed on trunk.

[Bug c/68193] _Generic -Woverflow false alarm

2023-08-05 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68193

--- Comment #8 from CVS Commits  ---
The master branch has been updated by Martin Uecker :

https://gcc.gnu.org/g:54be338589ea93ad4ff53d22adde476a0582537b

commit r14-3004-g54be338589ea93ad4ff53d22adde476a0582537b
Author: Martin Uecker 
Date:   Fri Aug 4 07:48:21 2023 +0200

c: _Generic should not warn in non-active branches
[PR68193,PR97100,PR110703]

To avoid false diagnostics, use c_inhibit_evaluation_warnings when
a generic association is known to not match during parsing.  We may
still generate false positives if the default branch comes earler than
a specific association that matches.

PR c/68193
PR c/97100
PR c/110703

gcc/c/:
* c-parser.cc (c_parser_generic_selection): Inhibit evaluation
warnings branches that are known not be taken during parsing.

gcc/testsuite/ChangeLog:
* gcc.dg/pr68193.c: New test.

[Bug c/68193] _Generic -Woverflow false alarm

2023-08-03 Thread muecker at gwdg dot de via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68193

Martin Uecker  changed:

   What|Removed |Added

 CC||muecker at gwdg dot de

--- Comment #7 from Martin Uecker  ---
PATCH: https://gcc.gnu.org/pipermail/gcc-patches/2023-August/626319.html

[Bug c/68193] _Generic -Woverflow false alarm

2019-05-21 Thread la...@linux-mips.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68193

Ladislav Michl  changed:

   What|Removed |Added

 CC||la...@linux-mips.org

--- Comment #6 from Ladislav Michl  ---
Created attachment 46391
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=46391&action=edit
Ternary if

That ternary operator makes warning disappear. In the testcase 'gcc -Woverflow
-o x x.c' gives:
x.c:14:9: warning: unsigned conversion from ‘int’ to ‘unsigned char’ changes
value from ‘1000’ to ‘232’ [-Woverflow]
   baz = 1000;
 ^~~~
x.c:16:9: warning: unsigned conversion from ‘int’ to ‘unsigned char’ changes
value from ‘2000’ to ‘208’ [-Woverflow]
   baz = 2000;
 ^~~~
while 'gcc -DNO -Woverflow -o x x.c' silently ignores overflow.
I would welcome any advice, how o properly categorize this bug, so eventually
new bugreport will be created.

Thank you.

[Bug c/68193] _Generic -Woverflow false alarm

2015-12-02 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68193

--- Comment #5 from Marek Polacek  ---
Yes, so this would be somehow tied to c_inhibit_evaluation_warnings as in we
warn for
  0 ? foo () : 2;
if foo() wasn't declared but not for the div-by-zero here:
  0 ? 1 / 0 : 2;

[Bug c/68193] _Generic -Woverflow false alarm

2015-12-02 Thread joseph at codesourcery dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68193

--- Comment #4 from joseph at codesourcery dot com  ---
I agree delaying warnings would help, but you'd need to distinguish 
warnings relating to execution of the code that should be disabled in 
unevaluated code from warnings that should always be present (which 
include but aren't limited to pedwarns).  For example, you shouldn't lose 
a diagnostic for an implicit function declaration just because it's in an 
unevaluated _Generic selection.

[Bug c/68193] _Generic -Woverflow false alarm

2015-12-02 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68193

--- Comment #3 from Marek Polacek  ---
I think some kind of delayed warning could help (so parse expressions and print
possible warnings to some "printer" and then print warnings from this "printer"
only for the association that matched).  Because of "default:" selectors we
can't parse just the one that matches.

[Bug c/68193] _Generic -Woverflow false alarm

2015-12-02 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68193

Marek Polacek  changed:

   What|Removed |Added

 CC||mpolacek at gcc dot gnu.org

--- Comment #2 from Marek Polacek  ---
The problem here is that after we've parsed the selector (with warnings
inhibited), we go over all the associations: process the type-name, then parse
assignment-expression of the association also using c_parser_expr_no_commas,
but this time without the warnings inhibited.  We should probably disable
warnings when processing the associations and only warn for matched_assoc.  But
I can't readily conceive how to do that.

[Bug c/68193] _Generic -Woverflow false alarm

2015-11-03 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68193

Richard Biener  changed:

   What|Removed |Added

   Keywords||diagnostic
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2015-11-03
 Ever confirmed|0   |1

--- Comment #1 from Richard Biener  ---
Confirmed.