[cleanup] Remove warning about index access out of bounds.
Closes #35 (closed).
@simon.praetorius: This is the fix I had for the warnings, however, I'm not sure if this is the best way to fix this.
Merge request reports
Activity
- Resolved by Simon Praetorius
Thanks. I will have a more detailed look. My initial solution broke something in my testsuite - so it was wrong.
252 252 { 253 253 for( int k = 0; k < dim-1; ++k ) 254 254 jacobianTransposeds[ m+i ][ dim-codim-1 ][ k ] = -origins[ m+i ][ k ]; 255 jacobianTransposeds[ m+i ][ dim-codim-1 ][ dim-1 ] = ct( 1 ); 255 if( dim - codim - 1 >= 0 ) The same condition would also be useful in the line above (254), since also there the corresponding array element is accessed. Assuming the conditions in the
assert()
in the first line of that function hold, in the whole else-block it holdscodim < dim
. And thusdim - codim - 1 >= 0
. We could thus also transform the whole else-block into anelse if (codim < dim)
block. But then we would have a missing return path for the potentially impossible casecodim > dim
.So, I was thinking. What if we transform the
assert()
checks in the top into proper exceptions that are always checked. Is this method anyhow time-critical? The introduced if-clause inside an inner loop is probably not performance-enhancing.changed this line in version 2 of the diff
added 1 commit
- cd91d194 - Handle all cases in referenceEmbeddings explicitly
added 6 commits
-
cd91d194...a51164b6 - 4 commits from branch
master
- d231994d - [cleanup] Remove warning about index access out of bounds.
- 3996749d - Handle all cases in referenceEmbeddings explicitly
-
cd91d194...a51164b6 - 4 commits from branch
mentioned in merge request !238 (closed)
This MR fixes the warnings mentioned in #35 (closed), but not all warnings shown by gcc12 with
-Wall
. There are more places in other functions. It would be interesting whether there is an underlying pattern / source of the warning that we could fix instead of the symptoms only.mentioned in commit d1d63a4d
There are still a few warnings left. The question is: What happens in the case that
dim == 0
? Thencodim
must be0
as well, due to0 <= codim <= dim
. This needs to be added as a check, i.e.,if( 0 < codim && codim <= dim ) // => dim > 0
The second check should always be true, thus does not change the logic.
mentioned in merge request !239 (merged)