https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87173
Bug ID: 87173 Summary: -Walloc-size-larger-than= silently fails for operands/size values larger than __SIZE_MAX__ Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: jozef.l at mittosystems dot com Target Milestone: --- Created attachment 44640 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44640&action=edit testcase.c Exposed by gcc.dg/Walloc-size-larger-than-{4,5,6,7}.c for msp430-elf, on latest trunk. - If the operand to the allocation function being checked is larger than __SIZE_MAX__, no warning is emitted. - If the value passed to -Walloc-size-larger-than= is larger than or equal to __SIZE_MAX__, no warning is emitted. e.g. for msp430-elf, where __SIZE_MAX__ is 65535. testcase.c attached. > msp430-elf-gcc -O -ftrack-macro-expansion=0 -Walloc-size-larger-than=65534 > testcase.c -S > testcase.c: In function 'f': > testcase.c:6:3: warning: argument 1 value '65535' exceeds maximum object size > 65534 [-Walloc-size-larger-than=] > 6 | T (__builtin_malloc (a)); > | ^ > testcase.c:6:3: note: in a call to built-in allocation function > '__builtin_malloc' The expected warning for 65536 (__SIZE_MAX__ + 1) exceeding maximum object size is missing. Again, with __SIZE_MAX__ as the parameter to -Walloc-size-larger-than= > msp430-elf-gcc -O -ftrack-macro-expansion=0 -Walloc-size-larger-than=65535 > testcase.c -S No warnings output.