Media
Video
Podcast
Powered by RedCircle
WG21 October mailing (cont.), fast math
Mailing - 80 papers, 41 new!
New papers
-
Follow-up C++ is the next C++
- Reddit thread exploded a bit – curiously, it looks like most commenters didn’t actually read the paper but are responding to the catchy title.
-
P2632R0. A plan for better template meta programming facilities in C++26. Big plans. Separate proposals for each planned feature. Uses Circle by Sean Baxter as an implementation example.
-
P2644R0. Get Fix of Broken Range-based for Loop Finally Done, by Nicolai Josuttis. A more general fix is not coming, it seems. But we have P2012. Maybe it is good enough?
-
P2656R0. C++ Ecosystem International Standard. Interoperable tools, what a concept.
-
P2658R0. Temporary storage class specifiers. More dialects?
-
P2668R0. Role based parameter passing. Parameter attributes like in Cpp2, or automatic parameter handling like in Carbon.
-
P2670R0. Non-transient
constexpr
allocation, by Barry Revzin. -
P2672R0. Exploring the Design Space for a Pipeline Operator, by Barry Revzin. The pipeline operator
|>
lives (maybe). -
P2676R0. The Val Object Model. Food for thought for a future C++. (David Sankel is at Adobe now, huh.)
-
P2677R0. Reconsidering concepts in-place syntax. Bring back
auto{T}
! -
P2688R0. Pattern Matching Discussion for Kona 2022. Can we have pattern matching in C++26, pretty please? Also,
match
is nicer thaninspect
, IMHO.
Contracts!!
- P2659R0. A Proposal to Publish a Technical Specification for Contracts, by Brian Bi, Bloomberg.
- P2660R0. Proposed Contracts TS. P2661R0. Amendments. Uses attribute-based contract syntax.
- P2680R0. Contracts for C++: Prioritizing Safety, by Gabriel Dos Reis
Fast math flag in libraries
Brendan Dolan-Gavitt wrote an article called Someone’s Been Messing With My Subnormals!, in which he describes an intrusive nature of the GCC/Clang compiler switch -ffast-math
.
TL;DR: After noticing an annoying warning, I went on an absurd yak shave, and discovered that because of a tiny handful of Python packages built with an appealing-sounding but dangerous compiler option, more than 2,500 Python packages—some with more than a million downloads per month—could end up causing any program that uses them to compute incorrect numerical results.
The discovery:
It turns out (somewhat insanely) that when
-ffast-math
is enabled, the compiler will link in a constructor that sets the FTZ/DAZ flags whenever the library is loaded — even on shared libraries, which means that any application that loads that library will have its floating point behavior changed for the whole process. And-Ofast
, which sounds appealingly like a “make my program go fast” flag, automatically enables-ffast-math
, so some projects may unwittingly turn it on without realizing the implications.
Also, apparently, if you use -Ofast
, -fno-fast-math
does NOT disable the auto-enabled -ffast-math
! WHAAAAT
The author wrote a Python script (Gist) to check if a library was compiled with -ffast-math
.
Pretty crazy. Be careful with your math compiler options.
Twitter: new tech vs. veteran
New to tech: This will totally work.
Tech veteran: There’s no way that works.
New to tech: I’m proud that my code worked on the first try.
Tech Veteran: I’m suspicious because my code worked on the first try.
New to tech: This code has been running for 2 years, we should rewrite it.
Tech Veteran: This code has been running for 20 years, I’m starting to feel like maybe we’ve got the bugs out.
New to tech: I am a magician. I create things from pure thought.
Tech Veteran: I am a plumber.