C++ Logo

std-proposals

Advanced search

Re: [std-proposals] P4334R0 C++ Contracts

From: Jonathan Grant <jgrantonline_at_[hidden]>
Date: Fri, 21 Aug 2026 14:49:41 +0100
On 19/08/2026 14:30, Peter Bindels via Std-Proposals wrote:
>
>
> On Wed, Aug 19, 2026 at 3:26 PM Rainer Deyke via Std-Proposals <std-proposals_at_[hidden] <mailto:std-proposals_at_[hidden]>> wrote:
>
>
>
> On 8/19/26 05:37, Ville Voutilainen via Std-Proposals wrote:
> > On Wed, 19 Aug 2026 at 05:54, Sebastian Wittmeier via Std-Proposals
> > <std-proposals_at_[hidden] <mailto:std-proposals_at_[hidden]>> wrote:
> >>
> >> If P2900 is staying, can you define (= propose) a 5th mode that acts like compile_assert and also hope that the implementations give better error messages and locations than an undefined violation handler?
> >
> > I don't know about others, but yes, yes I can: https://godbolt.org/z/xPz8hjcYY <https://godbolt.org/z/xPz8hjcYY>
>
> I don't see the precondition violation. `use_definitely_unsound` is a
> perfectly fine function for getting a -1 so long as its implicit
> precondition of not passing in a vector of exactly 5 elements is met.
> Nothing in the program violates this implicit precondition.
>
> Implicit preconditions still exist, right? There is no way to encode
> every precondition into something the compiler understands.
>
>
> If a branch exists with definite UB but it's never called is the program still ill-formed? For my own software I want that to be yes, but for C++ in general I think so far we have no, and changing such a thing will be a breaking change for many.

QoI? I expect some static analyzers may check more control-flow paths than those in a particular execution, not reached during testing. Otherwise need to add a way to exercise that path (maybe a test menu that can call it from a developer build?), so it is checked.

Kind regards
Jonathan

>
>

Received on 2026-08-21 13:49:49