[Bug middle-end/114627] undefined behavior in tree-profile.cc while compiling gcc.misc-tests/gcov-18.c

2024-04-09 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114627

--- Comment #2 from GCC Commits  ---
The master branch has been updated by J?rgen Kvalsvik :

https://gcc.gnu.org/g:a2447556a5405d2cde20afc134b90cd1d199ce04

commit r14-9864-ga2447556a5405d2cde20afc134b90cd1d199ce04
Author: Jørgen Kvalsvik 
Date:   Mon Apr 8 15:19:55 2024 +0200

Generate constant at start of loop, without UB

Generating the constants used for recording the edges taken for
condition coverage would trigger undefined behavior when an expression
had exactly 64 (== sizeof (1ULL)) conditions, as it would generate the
constant for the next iteration at the end of the loop body, even if there
was never a next iteration. By moving the check and constant generation
to the top of the loop and hoisting the increment flag there is no
opportunity for UB.

PR middle-end/114627

gcc/ChangeLog:

* tree-profile.cc (instrument_decisions): Generate constant
at the start of loop.

[Bug middle-end/114627] undefined behavior in tree-profile.cc while compiling gcc.misc-tests/gcov-18.c

2024-04-08 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114627

Richard Biener  changed:

   What|Removed |Added

Summary|[14 Regression] undefined   |undefined behavior in
   |behavior in tree-profile.cc |tree-profile.cc while
   |while compiling |compiling
   |gcc.misc-tests/gcov-18.c|gcc.misc-tests/gcov-18.c
   Target Milestone|14.0|---

--- Comment #1 from Richard Biener  ---
it's not a regression from older GCC since -fcondition-coverage is new