This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: _FORTIFY_SOURCE for std::vector


On Fri, Jun 01, 2012 at 03:09:19PM +0200, Paolo Carlini wrote:
> On 06/01/2012 02:53 PM, Florian Weimer wrote:
> >I've seen the variable, but I don't understand how to use it.  I
> >would like to add something about it to the testing documentation.
> Just copy what *all* the other testcase in the library testsuite
> have, just define it, with attribute unused. If you are curious why,
> just look inside testsuite_hooks.h
> >3- We definitely need a comment explaining *who* provided _M_range_check
> >
> >Sorry, I don't understand this suggestion.
> You are right, sorry, I went through your changes too quickly and
> didn't realize that you are just using the existing _M_range_check.
> Anyway, I confirm that probably we want something more consistent
> with debug-mode, thus not throwing in this case. Maybe just a
> __builtin_abort(), I don't know. Or adjust the code in c++config to
> make available a non-trivial __glibcxx_assert also when
> _FORTIFY_SOURCE > 0.

The standard -D_FORTIFY_SOURCE failure is __chk_fail (), so IMNSHO
if this is presented as _FORTIFY_SOURCE check, it should call that
and not some other function.  You'd need to use
#if __USE_FORTIFY_LEVEL > 0
test instead (as __chk_fail is only provided by glibcs that on
_FORTIFY_SOURCE definition sets __USE_FORTIFY_LEVEL), but it would be
consistent with all other fortification failures (and, even
-fstack-protector failures are similar).

Or of course if you want it to do something else on failures, better
enable it using a different macro.

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]