By default, GCC is not an Ada compiler and has not been one for years, because
stack overflow checks are disabled by default and require an explicit switch
(-fstack-check).  The rationale, as I understand it, was that stack overflow
checks were expensive in terms of CPU usage.

However, the rationale is much less valid now that CPUs are more powerful and,
more importantly, thanks to the new static stack analyzer in GCC which should
allow elimination of some stack overflow checks.

The drawback of the current situation is that almost every new user of Ada, at
some point, is surprised because they don't get the expected Storage_Error.  In
other words, GCC fails the Law of Least Astonishment.

Stack overflow checks can always be disabled explicitly with -fno-stack-check
or pragma Suppress.

Therefore: please enable stack overflow checks by default.

GCC supports two ways to implement stack overflow checks: using guard pages
called "probes", and inserting stack checking code into every subprogram.  The
probes require support from the both OS and hardware, so are not suitable for
all targets.  Moreover, they can miss stack overflows if a subprogram writes to
a page *after* the guard page (rather that into it).  GCC has a warning about
this situation.  Therefore, I suggest a new command-line switch to force
insertion of stack checking code (rather than guard pages) for those programs
that trigger the warning.


-- 
           Summary: Please enable stack checking (-fstack-check) by default
           Product: gcc
           Version: 4.2.2
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: ada
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ludovic at ludovic-brenta dot org


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

Reply via email to