C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Second draft of a __COUNTER__ proposal

From: Jeremy Rifkin <rifkin.jer_at_[hidden]>
Date: Mon, 26 Aug 2024 14:15:50 -0500
Good idea. I gave that a try as well as another approach but was
unable to produce a sufficiently large __COUNTER__ before gcc
segfaulted after (around a count of 270 million). I'm impartial on
specifying a 32-bit counter vs a 64-bit counter, both seem reasonable
to me.

Jeremy


On Mon, Aug 26, 2024 at 1:25 PM Thiago Macieira via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> On Monday 26 August 2024 11:08:48 GMT-7 Jeremy Rifkin via Std-Proposals wrote:
> > > Is overflow anything that happens in reality, ever?
> >
> > Not that I know of, but I will ask some folks I know who spend more
> > time stress testing the preprocessor than I. I agree that __COUNTER__
> > overflow should basically never happen and if it did it would be the
> > least of your problems.
>
> Because it is the preprocessor, it's not that difficult to trigger it.
>
> - A.h has 2048 uses of __COUNTER__ and no #include guard
> - B.h includes A.h 2048 times
> - C.cpp includes B.h 1024 times
>
> This is unlikely, but not impossible.
>
> It's also easily fixed by saying the counter is an intmax_t.
>
>
> --
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
> Principal Engineer - Intel DCAI Platform & System Engineering
>
>
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2024-08-26 19:16:04