r/cpp • • 5d ago

Prediction c++26

Since there's no kalshi market for c++ standards, put your predictions below for the upcoming second dis.

49 Upvotes

132 comments sorted by

44

u/ImNoRickyBalboa 5d ago

It will fail unless they drop contracts. Which they can't because they tied it to library hardening, so.... It will fail and there will be much clenching of hands and grinding of teeth 

20

u/James20k P2005R0 5d ago

Removing the library hardening tie in isn't nearly as complex as it had been made out to be by some, there's earlier versions of the paper that were not based on contracts

https://isocpp.org/files/papers/P4446R0.pdf

3

u/ImNoRickyBalboa 5d ago

Yeah, there was some hyperbole (Tm) in that response 🙂 I added my more nuanced thoughts.

5

u/ImNoRickyBalboa 5d ago

Let me be more nuanced in what I think the actual outcome will be. The draft as initially proposed will/would fail, so there will be a compromise.

There will be a revised ballot removing contracts from the draft. There is precedent for this: concepts was dropped for c++0x. It will delay official ISO publication, but no party here wants to kill ISO.

Library hardening can be reworded to its earlier non contracts spec, and contracts could be moved into TS. This is likely an acceptable compromise for all parties and allows everybody to move forward

24

u/azswcowboy 5d ago

Uh, no. Assuming SC22 takes the wg21 recommendation a modified 26 with the changes from Brazil will go back to the NBs for approval. If approval fails the project will be cancelled and the committee will continue towards 29 with contracts still in. The covenor has already said that’s what he’ll do. The committee soundly rejected any removal of contracts and hated the TS option even more.

12

u/ImNoRickyBalboa 5d ago

Even if they "win" with the proposed changes, there will be damage and credibility issues with the WG. They spent over a year arguing that in-source enforcement labels weren't needed for C++26 despite strong opposition. Throwing that in now looks more like gamesmanship than wisdom. They ignored and dismissed real, objective criticism of the design and security implications for over a year.

But we'll see what happens.

Personally I've lost quite some respect and faith in the WG and its processes. Big companies like Google are scaling down their participation to "minimal". The WG has become an echo chamber out of step with broader industry concerns, and is alienating a large body of c++ experts.

13

u/foonathan 5d ago

They spent over a year arguing that in-source enforcement labels weren't needed for C++26 despite strong opposition. Throwing that in now looks more like gamesmanship than wisdom

The plan always was to add labels in the C++29 time frame, they just weren't ready for C++26. Yet some people insisted that they absolutely need the feature, so a minimum enforcement label solution was pre-adopted.

Of course it's gamesmanship; it was a compromise.

They ignored and dismissed real, objective criticism of the design and security implications for over a year

No, those criticisms have been discussed for years. There are either solutions planned for C++29, which simply weren't ready yet, or a different set of tradeoffs prioritized.

The WG has become an echo chamber out of step with broader industry concerns,

That might be true, but I didn't see that with contracts.

and is alienating a large body of c++ experts.

I wouldn't classify the opposition to contracts as a "large body".

10

u/Disastrous-Jaguar541 5d ago • Bravo

I am speaking as an outsider, but my understanding is quite different from yours, My understanding is that an overwhelming majority o the WG wanted contracts in, with objections from a small but potent group, including Bjarne Stroustrup.

That minority then tried to force its will by convincing a group of national bodies that until this point had no objection to contracts to vote no. It is this minority that faces credibility issues.

13

u/azswcowboy 5d ago

Spoken like a person not involved. The fact that the committee stuck to its guns on contracts is indicative of listening to embedded and automotive members that very much want this feature. Google wound down their attempt to dominate things years ago. The vote, in fact, indicates listening to the majority of users and members. Not to the FUD of less than 20 members opinions.

6

u/ImNoRickyBalboa 5d ago

It looks terrible from the outside. I'm sure that those in the club that can afford to travel around the world to mingle with the 'club' would like to differ.

 There's a lot I would love to see happen in c++, an overly complicated and fidgety contracts standard is not one of them.

15

u/Daniela-E Living on C++ trunk, WG21 |🇩🇪 NB 5d ago

... those in the club that can afford to travel around the world to mingle with the 'club' ...

🤔I'm not sure if you are fully aware of how things work, are you?

No member is required to travel if they prefer not to. In-person meetings are not even an ISO requirement AFAIU, some WGs that I'm technically a member of rarely (never?) run them physically.

This time, a majority of members chose not to take on the burden of attending in person - for various reasons I presume. Some people like to extend their stay at or near the location of the meeting to enjoy vacation there. Some people prefer to do what you assinuate: meet others face-to-face.

12

u/serviscope_minor 4d ago edited 3d ago

> an overly complicated and fidgety contracts standard is not one of them

Do you have any concrete criticisms? In what way is it "overly complicated" or "fidgety". To me as someone completely uninvolved with the standards process, it looks to basically be a really clean standardization of a lot of random messy, ill specified assert macros, but with a bunch of got-yas cleaned up like:

* constifiaction is now a thing which is good because it's what you mean.

* mixed mode is now not IFNDR, so if you have cursed builds you won't get UB

* post conditions now run on all exit points of a function, guaranteed

There's nothing fiddly about it.

23

u/pkasting Valve 5d ago

It will pass. Not unanimously, but more than half the NBs that voted no last time will either vote yes or abstain.

30

u/javascript 5d ago

If I bet $1 on "The whole committee gives up and switches to Rust" what's the payout?

42

u/Wonderful-Habit-139 5d ago

Programmer socks.

19

u/bearheart 5d ago

<dr evil voice> One MILLION dollars </>

2

u/javascript 5d ago

I'll take it

1

u/13steinj 5d ago

Problem with these platforms is they decide the definitions.

Define "The whole committee"? Define "gives up"? Define "switches"?

There's an argument to be made that this has already happened. That said, the Contracts safety drama is a bit unrelated to Rust or not.

19

u/ConcertWrong3883 5d ago

If it passes some standards people will leave.
If it is removed some standards people will leave.
I hope some standards people will leave.

13

u/[deleted] 5d ago

WG21 has strong consensus. This time, it will pass.

22

u/ts826848 5d ago

Depending on who you asked it had "strong consensus" last time as well, so that in and of itself is clearly not sufficient to get the draft over the finish line.

1

u/13steinj 5d ago

Approximately 10:1 ratio! The entire problem is the consensus is meaningless internally.

9

u/13steinj 5d ago • Bravo Popcorn

Slopped up a market real quick for some lols.

https://13steinj.github.io/cpp26_predictions/

6

u/New_Salamander_4592 5d ago

man you guys really are addicted to gambling

6

u/FitReporter9274 5d ago

This version will pass the NB’s.  But the weight of the C++ governance framework and crippling devotion to backwards compatibility will continue to drag the language deeper and deeper into irrelevance. 

4

u/-dag- 4d ago

Unfortunately this is very true. We need a new approach. 

I've been using C++ for almost 30 years. I love it. I'm very distressed by the way the process has not worked for the last five years or so.

3

u/burlingk 5d ago

So, I've not been to deep in this all lately, but, like, what is the big upset over contracts?

5

u/Aerocatia 5d ago

I think it is likely to fail again and I do not think contracts are worth potentially delaying for years the time when we can actually use the other features in C++26.

16

u/azswcowboy 5d ago

Then 26 is cancelled and work will continue on 29 with contracts still in. I detailed this in another reply.

6

u/_w62_ 5d ago

So if 29 fails, then continue on 31 with contracts. If 31 fails, continue on 34? So far and so forth. Do I understand it correctly?

4

u/azswcowboy 4d ago

Yes. Or perhaps, at some point the instigators will realize that the ship has sailed and instead of fighting will move on — let’s hope that’s now. Or WG21 leaves ISO - that discussion became much more serious last week.

1

u/_w62_ 4d ago

In that case, if there is always a second chance, then why bother if it fails the current C++26 or not?

-1

u/AstroFoxTech 4d ago

Or WG21 leaves ISO

Aren't they only "actually" relevant because of ISO though? Like, wouldn't that mean they just get replaced?

3

u/azswcowboy 4d ago

Correct. As far as I’m aware IEEE, ECMA and other standards approaches don’t suffer from the archaic rules. ISO processes are in fact modeled similar to the UN under the thought that countries might have a national interest in some particular aspect. Maybe that’s true in say electricity distribution, but I don’t see that for a programming language.

3

u/kritzikratzi 4d ago edited 4d ago

i hope they take their time. worst case they skip c++26 and go directly to 27/28/29.

those are tricky problems, no need to rush. also it gives the rest of the world time to implement and use modules correctly 🌱

2

u/tartaruga232 MSVC user, r/cpp_modules 4d ago

I think it will pass.

1

u/-dag- 5d ago

It will pass, but only because NBs want something and the committee is stubborn. Contracts will be hardly used at all, worse than modules. 

22

u/alexeiz 5d ago

Why won't contracts be used? The entry barrier for contracts is much lower than for modules. Only compiler support is needed, whereas for modules it's compiler, library and build tools. GCC 16 can already compile code with contracts.

1

u/UndefinedDefined 5d ago

You cannot control contracts at a library level, but you can control asserts. Contracts are basically useless except for people who designed them.

4

u/alexeiz 5d ago

If I'm writing a library I probably won't use contracts. But if my code compiles into an executable, why can't I use contracts? I'm fully in control of the enforcement mode.

19

u/kammce WG21 | 🇺🇲 NB | Boost | Exceptions 5d ago

The new DIS contains contract controls so you can control this at a library level. I still fail to see why one would use asserts for something that they NEED checked. If that's the case then we have a solution, the humble if statement.

8

u/13steinj 5d ago

If that's the case then we have a solution, the humble if statement.

I think at this point all sides have lost their rationality and would spit at this.

7

u/johannes1971 5d ago

It does rather appear that all sides have entirely taken leave of their senses. The beauty of contracts is not that it gives us new syntax or new ways to invoke UB, it is that it puts information about the function in a machine-readable format that the compiler can use in various ways. The debate seems to center entirely on what the compiler is allowed to actually do with that information, with some groups apparently arguing that their way is the only way and everybody else needs to conform to their views of the universe. Maybe this is a mischaracterisation but that is impression I, as an outsider, got from browsing through various threads here on this group.

Well, it's my compiler. It's my software. Surely I am allowed to tell it what it can do with it? If I want to use it to verify my assumptions, but not necessarily abort my software while it is running, that seems a legal position. I've used enough if-statements for that in the past.

If I want to use it to hard-abort my software in production... First of all, your library should never pick that option for me; I at least want to give the user a chance to save their work before taking everything down. Or at least shut down a device that should not be left running without software control also being active.

And if I want to use that knowledge to further optimise, what exactly is the problem? That could have been the difference between GTA6 running at 60fps instead of 30fps...

4

u/kammce WG21 | 🇺🇲 NB | Boost | Exceptions 5d ago

What's wrong with if statements?

10

u/13steinj 5d ago

I have nothing wrong with if statements! I just feel as though all sides have lost all reason and are conflating conflicting definitions of "safety" and "what does it mean to test things?" in some weird philosophical sense, and they would not be happy with "use an if statement" as a resolution.

3

u/kammce WG21 | 🇺🇲 NB | Boost | Exceptions 5d ago

Sorry, it's the internet and I'm not exactly sure if you are saying that if statements should be an acceptable answer or are you saying that there are cases where an if statement isn't the right solution for always enforced check.

I mean, for the purposes of documenting in code that your function has a precondition that, if violated, will call the contract violation handler, then sure, that's useful visually.

3

u/13steinj 5d ago

I am saying if statements are perfectly valid (to me) to have an always enforced check, over [contract] assertions. Which I think you said above here.

I am also saying (some) of the people arguing, both for and against contracts, have cases where they consider this not-an-option.

Because some people want contracts for "testing," others want contracts for "documentation," others want it for formal verification, others want it for some 4th thing, and all of these groups have at least some people that:

  • think that using it for one of the other reasons is invalid.
  • want their thing always enforced.
  • can't use an if statement to achieve their goal.

Hence why

I think at this point all sides have lost their rationality and would spit at this.

3

u/Wonderful-Habit-139 5d ago

They're not part of the API's contract/function signature.

3

u/kammce WG21 | 🇺🇲 NB | Boost | Exceptions 5d ago

Are there any other things do you want to declare as a part of the function signature? I know errors are another hot option that others want. Would something like allocating also be something you'd want to declare as a part of a function's signature? And is it important that this information have an enforcement mechanism that goes along with it?

3

u/Wonderful-Habit-139 5d ago

Yes I want errors Result<T, E> style, and I want to pass the allocator as well. I want to also pass an io interface so that I write the same code whether it's async or sync.

Let me know if I missed something.

→ More replies

-5

u/UndefinedDefined 5d ago

I don't think we are talking about the same thing.

4

u/kammce WG21 | 🇺🇲 NB | Boost | Exceptions 5d ago

What are you talking about?

-8

u/UndefinedDefined 5d ago

You can use whatever you want, the problem is that the ecosystem is not gonna use it. I'm really wondering why... why C++ has to become a graveyard of features nobody uses.

11

u/alexeiz 5d ago

What do you mean by the ecosystem? I'm going to use it for my code, somebody else is going to use it for his code. Does it count as the ecosystem?

-4

u/ConcertWrong3883 5d ago

Look at Boost, (almost) everyone uses it, if they want to use contracts, they have to:
specify the behavior under quick enforce, ignore, observe, custom handlers that throw exceptions and when it is permitted because if it sees a noexcept somewhere the application terminates, which is not what you wanted since you asked for an exception.
Using contracts has too much risk.

10

u/atariPunk 5d ago

Why would they need the custom handlers that throw exception?

I really don't understand what is that you are trying to say here.

Contracts (preconditions) are not for error handling. It's to tell the caller the requirements to call the function. It's the responsibility of the caller to ensure that those preconditions are meet before the call. If you don't properly valid them and compile it with ignore then it's on you, not the library authors.

1

u/ConcertWrong3883 4d ago

> Why would they need the custom handlers that throw exception?

In case you are not allowed to terminate.

5

u/atariPunk 4d ago

But who knows if it’s ok to terminate or not, is the application, not the libraries that imports.

Also, replacing the contract violation handler is not mandatory. It’s implementation defined https://eel.is/c++draft/basic.contract#handler-3

Plus, it’s probably an ODR violation if multiple handlers are installed in the same program.

→ More replies

1

u/alexeiz 5d ago

I agree with you regarding the library code. But for application code (and maybe even header only library code) the contract behavior can be fully controlled, right? Therefore it can see contracts being used for the application code.

-6

u/UndefinedDefined 5d ago

Ecosystem for me is hundreds of thousands libraries you can use. If none of them goes for contracts, was it worth it?

12

u/alexeiz 5d ago

Well, none of the new C++ standard features get immediately used in hundreds of thousands of libraries. By that measure most of recent C++ features are failures. Even for Boost "roughly 67 libraries are tagged C++11, 16 are tagged C++14, 4 are tagged C++17 (MQTT5, OpenMethod, Parser, Redis), and 1 is tagged C++20 (Cobalt)" (source: AI). No boost libraries are using C++23 features. Are all C++23 features a failure?

-3

u/UndefinedDefined 4d ago edited 4d ago

You are comparing the wrong thing. You can use whatever feature in C++ that doesn't bring issues with it, and this is what most projects do. Variadic templates, consteval, and so... these are all great features - even reflection. But then you see a feature that is either unfinished or brings problems that are known, unsolved, and it's still pushed. I think it's irrational to push something like this. There is a reason most projects use different ranges or regex implementation, and so on...

And C++23 probably is a failure, because initializing all locals, including huge arrays, that's nonsense. All my projects so far stay C++20 unless this is resolved. Honestly, if C++ becomes this language like "let's put runtime overhead everywhere" then it's not the language I want to use in the future. It's nonsense, totally against the core foundation of the language.

4

u/WeeklyAd9738 5d ago

You don't speak for the ecosystem.

-3

u/UndefinedDefined 4d ago

Let's see in 10 years how this is adopted. Based on what I know, I guess 1%.

1

u/WeeklyAd9738 5d ago

You don't put such checks on contracts to begin with. Use std::optional or std::excepted for such interfaces.

-2

u/UndefinedDefined 4d ago

What's this reaction even about? People want to replace asserts with contracts, and it's not possible, what kind of information you actually need to understand that?

3

u/serviscope_minor 4d ago

>people want to replace asserts with contracts, and it's not possible, what kind of information you actually need to understand that?

Informatino about WHY it's not possible might be useful to help understand that...

9

u/NewLlama 5d ago

Modules are great, btw.

-1

u/-dag- 5d ago

Never said they aren't. 

7

u/RishabhRD 5d ago

Why do you think contracts would be less used than modules? I am genuinely curious. IMO the lack of toolchain support contributes mostly to failure of modules. What’s the case with contracts?

0

u/UndefinedDefined 5d ago

Because both features suck. Modules are not used in general, 99.9% projects stay #include based (especially libraries), and it's gonna stay like that.

7

u/RishabhRD 5d ago

A code example would help me to understand why it sucks.

0

u/rileyrgham 4d ago

The fact that there's no standard and support still sucks?

-3

u/Wonderful-Habit-139 5d ago

It's not the code that sucks.

-9

u/13steinj 5d ago

Modules or contracts?

The modules example cannot be expressed in code, it sucks because of (at least IMO) the way it behaves with multiple modules.

Contracts similarly, decent chunk of the reasons are cross-TU behavior. In-TU behavior: what does these 5 functions do in observe mode?

void real(int* p) { /* whatever the real impl is */ }

void foo1(int* p) { assert(p && *p); real(p); }

void foo2(int* p) { assert(p); assert(*p); real(p); }

void foo3(int* p) { contract_assert(p && *p); real(p); }

void foo4(int* p) { contract_assert(p); contract_assert(*p);  real(p); }

void foo5(int* p) pre(p && *p) { real(p); }

11

u/Minimonium 5d ago

With correct input, they're all equal.

With incorrect input the program is in an invalid state, they all potentially invoke UB. :)

9

u/Qwertycube10 5d ago

You call it with nullptr, then it calls the contact holder and after that returns it dereferences the null pointer and invokes UB. This seems entirely sensible to me when you told the compiler "hey, let me proceed even when the preconditions are not met".

2

u/13steinj 5d ago

The problem is the inconsistency. foo4 is the only one where the contract call itself can invoke UB.

8

u/Qwertycube10 5d ago

That seems entirely consistent to me foo2 would work the same way if you created an observe mode for assert by #define ing assert to log/print and return. Hell at my job we literally have ASSERT which does exactly that, therefore foo2 would be UB if you called it with nullptr.

1

u/13steinj 5d ago

The problem is not "well if you created an observe mode." The problem is exactly "is observe a valid mode at all?" It actively adds a new footgun to the standard.

With mixed-mode contracts being implementation defined on top of that, which mode of the function are you getting when one of your libraries (intentionally or not) sneaks something past your build engineeers?

10

u/Qwertycube10 5d ago

Let's imagine that contracts aren't in the standard and your library instead gives you a doc comment clearly listing the preconditions. It is undefined what happens if you violate those preconditions because you don't know if they check those preconditions in the implementation.

The only footgun is forcing a contract assert to be observe or ignore when that assert guards some undefined behavior, which is something you have to explicitly do on purpose, and unlike some other c++ footguns just looks like an obviously bad idea. To me any forced observe assertion would be a massive red flag that you should be using an if statement and handling that case.

All that said I don't love observe and would be fine with contracts not having the observe semantic, if you're calling functions without meeting their preconditions than you are in a situation that is very difficult to rain about from there forwards.

TLDR: Don't violate your libraries' preconditions. Don't mark contracts as always observe.

5

u/serviscope_minor 4d ago

>The problem is not "well if you created an observe mode."

No: observe modes exist. They are already out there and widely used. This isn't a theoretical thing.

>The problem is exactly "is observe a valid mode at all?"

That's an interesting philosophical question.

p!=nullptr is part of the contract of real(), if you violate that your code is wrong. And UB since real() will be trying to do something with p.

Except now you have a bit of an improvement over hand-hacked asserts or just random UB since contracts block time travel optimizations from crossing them.

But also, what do you expect from observe mode in prod? Observe mode basically means "my code is probably wrong but let me know keep trucking anyway". The alternative being "enforce" or the existing NDEBUG which briefly translates to "#YOLO".

What are you expecting from observed contract violations?

> It actively adds a new footgun to the standard.

No, because observe mode asserts are already completely 100% allowed by the standard and in fact in use in the wild. The standard is basically essentially a new syntax for "if" statements with some useful guarantees, a documented means of compiler-flag based control and attached semantic meanings.

This no more introduces new UB than the new if(int x=;...) syntax which also modifies if statements. If you write UB inside if statements, you'll get UB. While C++ has UB, UB will continue to exist and just about every feature new or otherwise will have an avenue whereby you can invoke UB. To me this complaint is "no new feature that can ever trigger UB but only if that feature is contracts".

3

u/serviscope_minor 4d ago

>Contracts similarly, decent chunk of the reasons are cross-TU behavior. In-TU behavior: what does these 5 functions do in observe mode?

There is no observe mode for std::assert but it is available with other assert macro libraries. So what are you referring to here?

6

u/Ameisen vemips, avr, rendering, systems 5d ago

A lot of people - myself included - don't use modules because toolchain support still sucks and Intellisense still doesn't support them. Given that compilers have supported precompiler headers since forever (which are basically just state dumps) and already had had their own versions of modules beforehand (aside from GCC)... it's odd that so little progress has been made over time.

Overall, they suck because we still want to pretend these days that the computer building the code might not actually have files. And various other issues, like still wanting to never have more than a single pass during compilation.

1

u/johannes1971 5d ago

I've been thinking for a while that the C++ world is entirely too stuck on its current compilation model. I'd be more than happy to have multi-pass compilation if that meant not having to deal with headers anymore; most of what you find in headers is duplication anyway.

And I think the way to go about that is to eliminate 'files' as the intermediate medium ;-) Sure, we can _edit_ our software in files, but perhaps the first step in compilation should be to split each file into fragments that get individually stored in a database. For one thing, that lets us do much more fine-grained recompilation, as unchanged fragments wouldn't trigger any recompilation. And the database, since it contains fragments from all files in the project, could immediately eliminate repeated template instantiations.

5

u/Zero_Owl 5d ago

So modules aren't used because they suck, not because they aren't properly implemented? Quite a take this is.

-1

u/UndefinedDefined 4d ago

Please show me a single mainstream library, something that is not a hello-world kind of project, that fully embraced modules (and not just supports them). There is none, and it's gonna stay like this probably forever. People using modules have actually more work to do, need more macros to use, just to support something nobody really needs.

2

u/FrogNoPants 3d ago edited 3d ago

We can't say if modules sucks yet as there isn't a good implementation, though that does sorta indicate they are overcomplicated. Anyway, essentially nobody uses them, so we have no meaningful data one way or another.

Contracts seem rather simple to implement by comparison.

3

u/UndefinedDefined 3d ago

I think you answered the question regarding modules though. It's 2027 and C++20 is used extensively by industry, but without modules. Modules as they were specified cannot even be used to mechanically port most of the code to use them. Take for example a simple logging macro, or macros for unit tests, or a damn macro that specifies a library version for conditional compilation, or features library was compiled with - modules cannot be used if these are needed, and these are needed in most libraries. It was DOA.

Contracts - I cannot comment on usage yet, but they bring so many problems that I think it's not worth using them - and the verbosity... I never needed this feature in any project - asserts and assumptions have done a good job for me, and I think most projects are gonna keep what they already use. We will see, but I don't plan to use contracts in my OSS libs nor in products that I maintain, same for modules.

-4

u/-dag- 5d ago

New ways to screw up your build. 

5

u/RishabhRD 5d ago

How?

-3

u/-dag- 5d ago

Different contracts enforcement on object files. 

1

u/serviscope_minor 3d ago

More FUD. This is ALREADY a problem with normal C++. At least with contracts it's no longer UB.

0

u/WeeklyAd9738 5d ago

I'm already using them with modules. C++26 contracts are awesome.

2

u/Chuu 5d ago

Genuine question for anyone who says they'll just pull contracts and it passes -- does that mean you think they'll drop the standard library hardening as well? What else in C++26 is defined in terms of contracts?

14

u/azswcowboy 5d ago

There’s no scenario where contracts is pulled now - that was resoundingly rejected. I detailed this here

https://www.reddit.com/r/cpp/s/CjEpA9E4zH

2

u/othellothewise 5d ago

People who say that are misinformed, there is no chance that they will be pulled.

1

u/CorrodedX 5d ago

Maybe I am looking at this too simply, but what do contracts actually add that an "if" statement doesn't already do? It seems like you're just moving checks from the function body to the definition.

12

u/Nobody_1707 5d ago

It moves the precondtion check to the declaration, which is very useful because it means that the caller can handle the precondition check (and optimize it away if its trivially true) without the function definition needing to be inlined.

2

u/gracicot 2d ago

which is very useful because it means that the caller can handle the precondition check

I thought this was impossible with the way contract were defined?

1

u/-dag- 4d ago

But you still have the problem that some people (I am in this camp) want the compiler to be able to treat it as a kind of assume directive while others do not. And even if every caller knows it's safe for the compiler to do it, it still can't (in the sense is satisfying opponents) because the declaration is not the definition. 

These seem like very different things (safety vs. optimization) but the same syntax can drive both. Is there a way to support both without an explosion of syntax?

3

u/Nobody_1707 4d ago

I feel like the compiler should be able to do this under the as if rule for the, deliberately overly verbose, always enforced version. And I'm sure there's going to be a compiler extension that enables it eventually.

0

u/-dag- 4d ago

I think the key issue is that the compiler would want to get rid of the check entirely. If you're optimizing you really want as little conditional code as possible. 

4

u/serviscope_minor 4d ago

>but what do contracts actually add that an "if" statement doesn't already do?

That's the wrong question. The right question is what do contracts actually add that assert macros don't already do?

Contracts are a formalization of assert macros (which use if statements), not a formalization of if statements.

4

u/-dag- 4d ago

People want it to be both. Or neither.

That's the fundamental problem. Not everyone agrees what it should be. That alone is a huge red flag for me.

-5

u/Jasonl220 5d ago

It will pass or C++ as an ISO standard is dead

12

u/kitsnet 5d ago

Not so fast. We still have a few years to switch to C++20 in production.

14

u/aeropl3b 5d ago

This is overly dramatic, stop spreading FUD

6

u/serviscope_minor 4d ago

Is it?

It's a lot of hard, often tedious and slightly soul destroying work to be on a committee like this. The plus side is when you finally hash out a solution you've made a difference and can move forwards. With this extra layer of voting you now got a shadow committee which doesn't remotely represent the makeup of WG21 who have veto power.

Frankly that's just grim and makes a grim job grimmer. Sure it's not going to insta-collapse if the NBs reject again, but how many people are just going to drift off and find something actually rewarding to do with their lives?

1

u/epage 5d ago

There is a committee member posting here and elsewhere advocating for leaving ISO when discussing contracts and governance. No idea how strong of a catalyst will be needed for that to be a strong enough view to make the move but it makes it seem like a possibility so seems reasonable and not FUD for someone to bring up in a prediction thread.

1

u/aeropl3b 5d ago

Even if that is true, not saying it isn't, that is hardly the point. C++ is an internationally recognized and standardized language. Everyone currently invested in that wants ISO as it makes it possible to exchange source and expertise with a reasonably high degree of confidence. If someone on the committee is openly trying to undermine that, I have to imagine there are more than a few people going to have something to say about that.

1

u/epage 4d ago

ISO is not the only way to do that and as Rust is finding, lack of ISO isn't as much of a barrier as some people think. One of the bigger issues is the trademark: soneone on here said it is owned by ISO.

This does not mean I agree this should happen in this way, just that there is the possibility and it isn't FUD.

1

u/aeropl3b 4d ago

Sure, there are other ways. But the Rust model prefers ecosystem lock in a way C++ does not. How many different rust compiler vendors are there? How many build systems support Rust? If I want to install Rust dependencies for my project, what are my choices for the package manager? The language, at this point, is the tools.

Ask the same questions about C++. That is what ISO gets you.

-1

u/pjmlp 4d ago

How many different rust compiler vendors are there?

Rust on LLVM, Rust on GCC (work in progress), Rust on Visual C++, Ferrocene distro, Ada Core distro

How many build systems support Rust?

We can make the same exercise with JavaScript, Java, Python, regarding implementations, build systems, and package managers, while not being at ISO isn't an impediment for adoption, for the same companies that make use of C and C++.

Cargo naturally, Bazel, Soong

3

u/serviscope_minor 4d ago

> Rust on LLVM, Rust on GCC (work in progress), Rust on Visual C++, Ferrocene distro, Ada Core distro

That's basically LLVM, a beta WIP, LLVM, LLVM and LLVM again.

So the answer for all practical purposes is 1.

0

u/pjmlp 4d ago

Nope, Visual C++ backend is certainly not LLVM.

Have you ever tried to use XCode clang instead of upstream clang?

Because if you ever did, you would be aware LLVM isn't always a four letter acronym.

Also GCC re-implementation definitely counts, even if not yet 1.0.

2

u/serviscope_minor 4d ago

>Nope, Visual C++ backend is certainly not LLVM.

Are you saying VS has an independent compiler?

>Have you ever tried to use XCode clang instead of upstream clang?

So many times (thankfully not any more). It was usually running behind by a bunch in all meaningful ways plus a bunch of mac specific hacks. Apple always have to be special.

It was basically old clang. Not 100%, jut 99.5%.

> Also GCC re-implementation definitely counts, even if not yet 1.0.

No, not in this context.

C++ has multiple complete, independent production ready independent compilers. GCC, Clang, VS, IAR, Green Hill (I thin the latter two use EDG front ends with their own backends).

Rust doesn't.

There's one production ready compiler and a few distributions of that.

-1

u/aeropl3b 4d ago

Visual C++, afaik, is just Rust on Windows. Imo, anything windows doesn't actually count.

Ferrocene and Ada seem to just be snapshots of LLVM for Rust, with additional certifications and metadata tooling on top. Idk if that constitutes additional compilers, more like compiler wrappers.

GCC would be interesting.

For C++ Intel kind of still counts some they have a successfully broken OneAPI compilers on their own more than once. But Cray, AMD are all LLVM now, almost no edits. Solaris, cfront (kind of), Acorn, etc. Are entirely different stacks. PowerPC compilers from IBM (yes I know LLVM can target power, but IBM XL is different).

-1

u/chibuku_chauya 4d ago

Xmake as well.

-10

u/ImNoRickyBalboa 5d ago

There will be a revised ballot removing contracts from the draft. There is precedent for this: concepts was dropped for c++0x. It will delay official ISO publication, but no party here wants to kill ISO.

Library hardening can be reworded to its earlier non contracts spec, and contracts could be moved into TS. This is likely an acceptable compromise for all parties and allows everybody to move forward.

7

u/Minimonium 5d ago

Nah, doesn't work like this

0

u/drj__ 5d ago

Bro, just have C++26 and C++26.5

1

u/zowersap C++ Dev 4d ago

26.7

-4

u/samadadi 4d ago

I hope they drop contracts or I do not want the CPP26 to be passed at all.

-2

u/13steinj 5d ago

Nah man we need something better than this, give me a little bit I'll make a "market."