Xarn

@horenmar
115 Followers
26 Following
809 Posts
Still has opinions about testing, still maintains Catch2.
bloghttps://codingnest.com
githubhttps://github.com/horenmar

I want a compiler to optimize away the doubled up check of the static var initialization, is that too much?

https://godbolt.org/z/xsYT8nMd6

(Yes I know, it boils down to optimizing around atomics and nobody wants to touch that too much)

Compiler Explorer - C++

int opaque(); int adjust() { static int base = opaque(); return base; } int double_adjusted() { return adjust() + adjust(); }

https://godbolt.org/z/b66vhKb1f

Is there anything actually stopping the compilers to optimize wide_load1 into actually doing a wide load? As I understand the C++ memory model, relaxed atomic load should be reorderable with other loads.

Compiler Explorer - C++

uint8_t arr[4]; std::atomic<uint32_t> a1, a2; uint32_t wide_load1() { uint32_t ret = 0; ret |= arr[3] << 24; a1.load(std::memory_order_relaxed); ret |= arr[2] << 16; ret |= arr[1] << 8; ret |= arr[0] << 0; return ret; } uint32_t wide_load2() { uint32_t ret = 0; ret |= arr[3] << 24; ret |= arr[2] << 16; ret |= arr[1] << 8; ret |= arr[0] << 0; return ret; }

Since cplusplus/papers is down due to a meeting going on, anyone knows what's the current state of P1478?

There are some advantages to how GTest does value parametrization, but the amount of boilerplate to get even the most simple parametrization going means that we have ton of basically duplicated tests.

With Catch2 these 12 tests I am looking at would've been 1, because the barrier to go from 1 concrete test to a value parametrized test is tiny.

hey so apropos of nothing at all, anyone got any rust/c++ jobs going that won't irrevocably corrupt my eternal soul? (remote UK)

On LinkedIn: Remote
On careers.microsoft.com: 2 days/week in office.

Microsoft, I beg you, stop sucking at things for five damn minutes.

Getting angry about Discworld covers was not something I expected to do during slow Friday morning, but here I am.

Has the optimization story around atomics ever changed, or is it still "the compiler is allowed to optimize-away in-between states, but no compiler actually does"?

E.g. given
```cpp
void f1(atomic<int>& cnt) {
for (int i = 0; i < 1'000; ++i) {
++cnt;
}
}

void f2(atomic<int>& cnt) {
cnt += 1'000;
}
```

Going from f1 to f2 would still be allowed by the standard.

Maybe don't send unrendered html in the exception you send to your API users?

```
13:12:52 Connecting to https://api.github.com using xxx/****** (xxxxxx)
ERROR: Error while retrieving pull request 139 merge hash : org.kohsuke.github.ServiceDownException: <!DOCTYPE html>
<!--

Hello future GitHubber! I bet you're here to remove those nasty inline styles,
DRY up these templates and make 'em nice and re-usable, right?

Please, don't. https://github.com/styleguide/templates/2.0

-->
```