JDK-8006573 : Integer overflow checking
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Priority: P4
  • Status: Closed
  • Resolution: Won't Fix
  • Submitted: 2013-01-18
  • Updated: 2019-10-29
  • Resolved: 2015-03-09
Related Reports
Relates :  
Description
The constant pool version and symbol table, and possibly other places have integer overflow checks that might be undefined in C and C++.   This code should explicitly check if it would overflow (version == max int) after increment to be pedantic.
Comments
This specific area is being addressed by a different change. We'll not fix the general case. Closing as WNF
09-03-2015

more comments from Dean Long and David Holmes > I couldn't find anything specific in my copy of the C standard. But I know that we do assume that overflow leads to wrap-around on all supported platforms. > I don't know about the C standard, but I found it in the C++ standard. > I couldn't think of anything that gcc might try to optimize in this particular case. I do recall seeing overflow related optimizations in the past though, IIRC something like this: > > if (x > 0 && ++x > 0) {...} > > was compiled as: > > if (x > 0) { ++x; ... } > > David > This particular case may be safe, I'm not sure. Some of the relevant gcc flags: -fwrapv Assume signed arithmetic overflow wraps around -fstrict-overflow Treat signed overflow as undefined -Woverflow Warn about overflow in arithmetic expressions -Wstrict-overflow Warn about optimizations that assume that signed overflow is undefined -Wstrict-overflow= Warn about optimizations that assume that signed overflow is undefined -ftrapv Trap for signed overflow in addition, subtraction dl
23-01-2013