https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106738
Bug ID: 106738
Summary: -Wlarger-than triggering for *.LASAN0 section
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: frolov.da at phystech dot edu
Target Milestone: ---
The behaviour of the warning flag -Wlarger-than is described in documentationL
> warn whenever an object is defined whose size exceeds byte-size.
> -Wlarger-than=‘PTRDIFF_MAX’ is enabled by default. Warnings controlled by the
> option can be disabled either by specifying byte-size of ‘SIZE_MAX’ or more
> or
> by -Wno-larger-than.
> Also warn for calls to bounded functions such as memchr or strnlen that
> specify a bound greater than the largest possible object, which is
> ‘PTRDIFF_MAX’ bytes by default.
I've tried to build the next example:
#include <assert.h>
void foo () {
assert (false);
}
$ g++ -O2 -c -Wlarger-than=16 -fsanitize=address minimal.cpp
And got a warning:
cc1plus: warning: size of ‘*.LASAN0’ 192 bytes exceeds maximum object size 16
[-Wlarger-than=]
It looks like a false triggering. From my point of view the user should not
monitor the size of the analyzer section.
Moreover, if we would try to add another assert:
#include <assert.h>
void foo () {
assert (false);
}
void goo () {
assert (false);
}
Then we'll get:
cc1plus: warning: size of ‘*.LASAN0’ 256 bytes exceeds maximum object size 16
[-Wlarger-than=]