~skeeto/public-inbox

3 3

Re: My favorite C compiler flags during development

Details
Message ID
<de03219db2e6ede5dafd91eeb0747734@disroot.org>
DKIM signature
pass
Download raw message
I know this article is titled "C compiler flags" but one of the most 
underused for C++ is `-D_GLIBCXX_DEBUG` which gives bounds checks on 
standard containers. Beginners are particularly prone to this and it 
helps a lot.

Maybe it deserves a mention here, it is really unfortunate how lacking 
education is here.

Regards,

Re: My favorite C compiler flags during development

Details
Message ID
<20241114195022.kivfj6oqsva7lp6i@nullprogram.com>
In-Reply-To
<de03219db2e6ede5dafd91eeb0747734@disroot.org> (view parent)
DKIM signature
missing
Download raw message
Great tip! I've used it myself when working with C++. I like that it works 
in w64dk, too. I've added a note to the article mentioning it.

Re: My favorite C compiler flags during development

Details
Message ID
<20250112174810.zz7ipviygx5gzhew@nullprogram.com>
In-Reply-To
<de03219db2e6ede5dafd91eeb0747734@disroot.org> (view parent)
Sender timestamp
1736686090
DKIM signature
missing
Download raw message
Several times now your -D_GLIBCXX_DEBUG suggestion has reminded me to use 
it when testing or reviewing a conventional C++ program. Otherwise I would 
have forgotten! I'm forming a habit of enabling it automatically alongside 
sanitizers to cover the gaps.

Re: My favorite C compiler flags during development

Details
Message ID
<a223331561bf81252c596351308af6e3@disroot.org>
In-Reply-To
<20250112174810.zz7ipviygx5gzhew@nullprogram.com> (view parent)
Sender timestamp
1736724080
DKIM signature
pass
Download raw message
On 2025-01-12 17:48, Christopher Wellons wrote:
> Several times now your -D_GLIBCXX_DEBUG suggestion has reminded me to 
> use it when testing or reviewing a conventional C++ program. Otherwise 
> I would have forgotten! I'm forming a habit of enabling it 
> automatically alongside sanitizers to cover the gaps.

Great! This feature of libstdc++ definitely goes underused.

On a related point, GCC 15 is enabling _GLIBCXX_ASSERTIONS by default 
for -O0 builds. That's good progress.
https://gcc.gnu.org/gcc-15/changes.html
Reply to thread Export thread (mbox)