On Sun, 30 Apr 2023, Ville Voutilainen via Ext wrote:
> On Sun, 30 Apr 2023 at 04:47, Amir Kirsh via SG20 <sg20@lists.isocpp.org> 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
--
SG20 mailing list
SG20@lists.isocpp.org
https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.isocpp.org%2Fmailman%2Flistinfo.cgi%2Fsg20&data=05%7C01%7Cgdr%40microsoft.com%7C676d8d9fa55049a41fa508db499450ff%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638184673609846504%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=BBEDdjBb9qc%2FQewpktsPkJjFPd0Fmsb4icIM0im3oD0%3D&reserved=0