http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55095

--- Comment #5 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2012-10-28 
18:34:43 UTC ---
(In reply to comment #4)
> The constant folder (fold-const.c:int_const_binop_1) would seem to be the 
> place where overflow information would most readily be available for this: 
> as I understand it, it's specifically about constants, rather than the 
> generic issue that almost any left shift with nonconstant operands might 
> overflow.  If diagnosing there, you'd want to pass down a location a few 
> levels from fold_binary_loc (so changing lots of calls to const_binop to 
> pass a location).
> 
> (In any case, double-int will need a new interface to report whether shift 
> overflow has occurred.)

Is there some interface that I can directly call to perform the shift in the
largest available precision (or infinite precision if that is possible) and
then convert the result to the result type and compare the two values? That
seems much more straight-forward than going through fold-const. And it allows
to report what the result would have been and how much precision would be
needed for it, like clang does.

Reply via email to