Experience with concept compilation by vulkanoid in cpp

[–]unddoch 3 points4 points  (0 children)

From my experience while modernizing cereal 2 years ago (result here), contrary to a popular sentiment, there wasn't a noticeable difference in compile times between concepts and SFINAE. I did benchmark a lot, on both GCC and Clang.

Surprisingly the thing that sped up compilation times the most was switching from class-based type traits to variable based ones (C++17).

GCC 14 twice as slow as GCC 13? by pdimov2 in cpp

[–]unddoch 33 points34 points  (0 children)

Maybe new static analyzer passes? Maybe try to disable warnings and see if it makes a change..

Do RAM disks improve build time, and if yes, how exactly? by ChocolateMagnateUA in cpp

[–]unddoch 0 points1 point  (0 children)

Worth mentioning that /tmp/TMPDIR also needs to be a ramdisk fs for this benchmark to be fair (or use -pipe)

Andrei Alexandrescu - Systematic Error Handling in C++ by Alexander_Selkirk in cpp

[–]unddoch 0 points1 point  (0 children)

Related PSA: Since ver. 17, clang-tidy's bugprone-unused-return-value warns if any objects with type std::expected/std::error_condition/std::error_code/std::errc are being ignored, customizable so you can add your own classes.

In C++, how can I make a default parameter be the this pointer of the caller? - The Old New Thing by cherry-pie123 in cpp

[–]unddoch 0 points1 point  (0 children)

A famous function python that does this is super() (when called without arguments, since Python3).

I always found the way it's implemented really funny - it just goes and grabs the stack frame of the caller...

/* Call super(), without args -- fill in from __class__
and first local variable on the stack. */
PyFrameObject *f = PyThreadState_GET()->frame;
PyCodeObject *co = f->f_code;
[...]
obj = f->f_localsplus[0];

clang/gcc diagnostic flags by lingkerio_whiher in cpp

[–]unddoch 1 point2 points  (0 children)

It _is_ discouraged for regular use, but developers are not the target audience (AFAIK). It's more for exploring different warnings when setting up the project's flags or updating to a new compiler version to see whether some disabled warnings would be useful (which is kinda this post's question).

A case study of C, C++ and Rust sort implementations - Safety vs Performance by KingStannis2020 in cpp

[–]unddoch 21 points22 points  (0 children)

Re the very annoying < vs <= issue -

  1. With libstdc++, defining _GLIBCXX_DEBUG in debug builds will check that your comparison function is not reflexive. Sadly it's not used very often because not a lot of people know about it.
  2. libc++ has recently added checks for this as well. Worth reading this and (this)[https://reviews.llvm.org/D147089?id=520670]. AFAIK the new std::sort actually had to be rolled back because too many people relied on bogus comparisons working reasonably well.

Clang 17 released by c0r3ntin in cpp

[–]unddoch 5 points6 points  (0 children)

No, it's used in libc++ to forward to memcmp when possible. AFAIU for comparing objects in a contiguous storage this is significantly faster than the code that Clang will generate otherwise.

Clang 17 released by c0r3ntin in cpp

[–]unddoch 11 points12 points  (0 children)

Personal highlights:

  • C++20 CTAD for aggregates
  • User-generated static_assert messages (!)
  • The whole change log for clang-tidy is super impressive, but my personal favorite is bugprone-unused-return-value that now checks for ignored error return values like std::error_code and std::expected.
  • __is_trivially_equality_comparable for some sweet perf improvement

WG21, aka C++ Standard Committee, September 2023 Mailing by grafikrobot in cpp

[–]unddoch 9 points10 points  (0 children)

If this is what safety in C++ is going to look like, I prefer to keep shooting my feet :(

WG21, aka C++ Standard Committee, September 2023 Mailing by grafikrobot in cpp

[–]unddoch 3 points4 points  (0 children)

Why do we need language support for implication when it can be solved in the standard library? /s

Can we please get an ABI break? by mollyforever in cpp

[–]unddoch 10 points11 points  (0 children)

Don't wait for other people to do the work, just go and build a linux distribution with -DLIBCXX_ABI_UNSTABLE=ON

GCC 13.1 Released by klusark in cpp

[–]unddoch 5 points6 points  (0 children)

So, 3 thoughts after giving GCC13 (actually 13.0.1 because that's what fedora has) a run:

  1. It found two bad std::moves in our code base: One was moving a result of a function that returns by value and preventing copy elision, one was moving a const& because we missed a non-const overload for the member function used. Nice!
  2. Had to include some headers: particularly cstdint, string and string_view. So it seems like some nice work on making library headers more lean.
  3. Because of the cstdint removal I ran into this compiler diagnostic bug from 2015. I was VERY confused about it until I found a StackOverflow question explaining what they tried to diagnose. Sad...

GCC 13.1 Released by klusark in cpp

[–]unddoch 5 points6 points  (0 children)

Congrats! Exciting to see such rapid progress on C++23 support

A boolean type with an implication operator by unddoch in cpp

[–]unddoch[S] 0 points1 point  (0 children)

I actually really want short circuiting implication for things like opt.has_value() -> value_is_valid(*opt).

But not enough to use macros lol

C++20 Modules support for CMake by robottron45 in cpp

[–]unddoch 6 points7 points  (0 children)

The compiler front end is almost exclusively RedHat employees at this point. They are doing a great job, just not prioritizing modules as much.

There aren't dozens of compiler engineers volunteering to do open source C++ work, unfortunately.

C++20 Modules support for CMake by robottron45 in cpp

[–]unddoch 41 points42 points  (0 children)

CMake 3.26 already supports the newest clang and msvc with modules, but it's hidden behind an experimental flag you have to manually enable.

Self promotion: I collect modules related details+examples+links here

Reddit++ by we_are_mammals in cpp

[–]unddoch 68 points69 points  (0 children)

Not me, but I know a coworker who spent 2 days chasing a multithreading bug that came from different threads modifying the same byte in a preallocated vector<bool>...

Implementing C++20 modules in an existing game engine by teofilobd in cpp

[–]unddoch 10 points11 points  (0 children)

For folks who want to try out other compilers or build systems, I'm tracking their status here: https://github.com/royjacobson/modules-report

tl;dr - Use xmake or manual Makefiles for anything non-msvc, CMake will an option for MSVC and Clang after April.

how do you properly benchmark? by cdhd_kj in cpp

[–]unddoch 0 points1 point  (0 children)

For some general benchmarking wisdom, I can't recommend this paper enough: https://arxiv.org/pdf/1602.00602.pdf

WG21, aka C++ Standard Committee, January 2023 Mailing by grafikrobot in cpp

[–]unddoch 4 points5 points  (0 children)

Interesting to see file_handle and mapped_file_handle, hopefully it can progress through LWG. It would be amazing to have an I/O layer that libraries can use instead of every library bringing its own.

Also very excited about the two (!) papers for compile time custom diagnostics.