Re: Avoid removing an if (false) statement and its corresponding branch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I just tried it and it does work, even on O3, however I would like to avoid
allocating a variable if possible. It's a shame that gnu::used doesn't
seem to work with if statements (If anyone knows where to look in the
source code do tell me). But thanks for the suggestion nonetheless!

best regards,
Julian

On Sun, Jul 23, 2023 at 10:14 PM Gabriel Ravier <gabravier@xxxxxxxxx> wrote:

> On 7/23/23 14:45, Julian Waters via Gcc-help wrote:
> > Hi all,
> >
> > Is there a way to stop gcc from nuking an if (false) statement and the
> > corresponding branch from the compiled code for debugging purposes?
> > Even turning off all optimizations doesn't achieve this
> >
> > best regards,
> > Julian
>
> IMO the simplest way would be to define something like `static const
> volatile bool unoptimizable_false = false;` somewhere and use it in
> place of `false`, when you want to avoid the if statement being
> optimized out.
>
>




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux