zlacker

[parent] [thread] 2 comments
1. mort96+(OP)[view] [source] 2024-01-16 15:53:07
> Can you elaborate? What fast-math can sneak into a library that disabled fast-math at compile time?

A lot of library code is in headers (especially in C++!). The code in headers is compiled by your compiler using your compile options.

replies(1): >>dahart+C
2. dahart+C[view] [source] 2024-01-16 15:55:06
>>mort96+(OP)
Ah, of course, very good point. A header-only library doesn’t have separate compile options. This is a great reason for a float-sensitive library to not be header-only, right?
replies(1): >>mort96+h2
◧◩
3. mort96+h2[view] [source] [discussion] 2024-01-16 16:02:17
>>dahart+C
It's not just about being header-only, lots of libraries which aren't header-only still have code in headers. The library may choose to put certain functions in headers for performance reasons (to let compiler inline them), or, in C++, function templates and class templates generally have to be in headers.

But yeah, it's probably a good idea to not put code which breaks under -ffast-math in headers if possible.

[go to top]