Skip to content

gcc Werror about closing_iterator: -Werror=strict-overflow #1339

Answered by tinko92
wxy-creat asked this question in Q&A
Discussion options

You must be logged in to vote

I cannot replicate it, do you have a full example with GCC version and command line that generates this warning? I can only try to make a guess: If I understand this class and the warning (https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#:~:text=It%20warns%20about%20cases,on%20the%20optimization%20level.) correctly then this would mean, GCC makes some optimization that is only valid if no integer overflow occurs.

Maybe something like this: GCC sees that this class is instantiated with the end constructor and then sees several decrement-calls occurring in a loop. It deduces that this condition m_index-- < m_size will only ever be false in the first call to decrement, and in all subs…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by wxy-creat
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants