C++ Logo

sg20

Advanced search

Re: [isocpp-ext] namespace composition

From: Marc Glisse <marc.glisse_at_[hidden]>
Date: Sun, 30 Apr 2023 18:02:29 +0200 (CEST)
On Sun, 30 Apr 2023, Ville Voutilainen via Ext wrote:

> On Sun, 30 Apr 2023 at 04:47, Amir Kirsh via SG20 <sg20_at_[hidden]> wrote:
>>
>> I agree with Yehezkel that introducing address sanitizer as their guard is important.
>> As they may get index out of bounds also using std::array or C-Style arrays for example.
>
> Well.. introducing address sanitizer to newcomers is perhaps a
> distraction and a digression.

How is learning to use the compiler correctly a distraction? Is learning
to use a debugger also a distraction? Teaching students to use some kind
of debug mode while developing can save a lot of time (so can enabling
warnings). And it doesn't need to be perfect to be helpful.

AFAIK all implementations provide options to check out-of-bound vector
access. For gcc, it could be -D_GLIBCXX_DEBUG, or the lighter
-D_GLIBCXX_ASSERTIONS, or -fsanitize=address -D_GLIBCXX_SANITIZE_VECTOR
(the extra define is necessary to catch Amir's example).

-- 
Marc Glisse

Received on 2023-04-30 16:02:33