[Bug c/108798] New: -Woverflow fails to catch int8_t i=128;

2023-02-15 Thread divinity76 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108798

Bug ID: 108798
   Summary: -Woverflow fails to catch int8_t i=128;
   Product: gcc
   Version: 12.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: divinity76 at gmail dot com
  Target Milestone: ---

-Woverflow fails to catch int8_t i=128;
int8_t has a range of -128 to 127, 
yet following code: 
```c
#include 
int main(){
int8_t i=128;
(void)i;
return 0;
}
```
compiled with:
gcc prog.c -Woverflow

does not produce any warnings. I expected something like:
prog.c:3:15: warning: overflow in conversion from 'int' to 'int8_t' {aka
'signed char'} changes value from '128' to '-128' [-Woverflow]


Interestingly, compiling it with:
gcc prog.c -Woverflow -Wpedantic

catches the error. Also, increasing it to 256 or above also catches the error.
(but anywhere from 128 to 255 is not caught without -Wpedantic, it seems)

Tested with gcc 12.1.0 (released 2022-05-06) and gcc "13.0.1 20230214
(experimental)"

[Bug rtl-optimization/8537] Optimizer Removes Code Necessary for Security

2024-06-24 Thread divinity76 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=8537

Hans Henrik Bergan  changed:

   What|Removed |Added

 CC||divinity76 at gmail dot com

--- Comment #6 from Hans Henrik Bergan  ---
just for future reference, in >=C11 we have memset_s for this particular issue,
and in >=C23 we also have memset_explicit, both of which are not allowed to be
optimized out