-
Hello, I am getting:
on this line in file: closing_iterator.hpp: 148: the complete codes are: After checking other codes in this header file, I guess this warning might be caused by the constructor of struct closing_iterator: |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
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 |
Beta Was this translation helpful? Give feedback.
-
Thanks a lot. I think you are right. My GCC version is gcc-12.3.0 and I use -O2 to open compiler optimization. It can work without -O2. |
Beta Was this translation helpful? Give feedback.
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…