News for hackers. Stuff that matters.
Re:C++ Attribute: Likely, Unlikely by JonChesterfield on Sunday October 22, 2023 @07:32PM (#37980028)
This is a pretty coherent argument that that new feature is broken and best ignored. Hopefully that's the approach clang will take.

PGO is a mixed blessing and detracts a bit from the thrust of the article. The more obvious conclusion is to continue using builtin_expect (on the boolean guard of a branch) which works great and has done for ages.

Re:C++ Attribute: Likely, Unlikely by pjmlp on Monday October 23, 2023 @02:17AM (#37982171)
That is also covered by new C++ attributes, namely [[assume(expr)]].

However better not give data to the function that contradicts the condition if you don't want to figth nasal daemons.

Re:C++ Attribute: Likely, Unlikely by JonChesterfield on Monday October 23, 2023 @06:27AM (#37983743)
Glad assume(expr) is available, if it maps onto builtin-expect but confused by the UB reference. Why would taking the less likely path be undefined behaviour?

Edit. It's because assume does not map to expect, it maps to builtin_assume. So that's just another way to write undefined c++.

Re:C++ Attribute: Likely, Unlikely by pjmlp on Monday October 23, 2023 @07:35AM (#37984220)
Ah, I thought it was the same, I spend most of my C++ coding time on VC++ anyway.