[Bug c/35592] Want attribute to enable precision loss warning

egallager at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Feb 20 16:35:00 GMT 2019


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=35592

--- Comment #8 from Eric Gallager <egallager at gcc dot gnu.org> ---
Created attachment 45777
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45777&action=edit
testcase

(In reply to felix-gcc from comment #6)
> Sure. For example:
> 
>   char* c=malloc(lseek(somefd,0,SEEK_END);
> 
> on a platform where off_t is 64-bit, but where size_t is 32-bit.  For
> example: i686-linux with #define _FILE_OFFSET_BITS 64.
> 
> Now that I'm thinking about it, would it be possible to have a generic
> overflow warning in that context?  For example,
> 
>   malloc(p->len+1)
> 
> So that gcc sees I'm adding something there, and if the range is not clamped
> down before that gives an error?

I combined those into a testcase which is attached. I thought the new
-Walloc-size-larger-than= warning that (I think it was) Martin added would
catch it, but apparently not?


More information about the Gcc-bugs mailing list