Re: recommended optimization level when programming C++ contracts

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

 



On Thu, 23 Feb 2023 at 14:00, Saifi Khan <saifi.khan@xxxxxxxxx> wrote:
>
> Hi:
>
> was working through p2680r1 example with the code as follows.
>
> ---
> auto f (int i) -> int {
>       return i + 100;
> }
>
> int g (int j) [[pre: f (j) < j ]] {
>       int r { j - f (j)};
>       return 2 * r;
> }
>
> auto test () -> void {
>       g (5);
> }
>
> ---
>
> Environment
>  - Linux  6.1.0-3-amd64 x86_64 GNU/Linux
>  - Debian GLIBC 2.36-8) 2.36
>  - gcc version 13.0.1 20230215 (experimental) (GCC)
>
> What is not clear to me is the following.
>
> This works.
>
> ::  g++ -std=c++23 -fcontracts contract_01.cc
> ::  ./a.out
> contract violation in function g at contract_01.cc:8: f (j) < j
> terminate called without an active exception
> Aborted
> ::
>
> But this doesn't work !
>
> ::  g++ -std=c++23 -O3 -g2 -fcontracts contract_01.cc
> during RTL pass: final
> contract_01.cc: In function ‘int g(int)’:
> contract_01.cc:13:1: internal compiler error: in gen_inlined_subroutine_die, at dwarf2out.cc:25002

But this is just a compiler bug, why are you trying to infer anything
about recommended optimization levels from a bug?

All this means is GCC has a bug, it doesn't mean you should or
shouldn't use optimization with contracts. Please report the bug.




[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