[CDRIVER-4163] clang version checks for __builtin_bswap are incorrect Created: 16/Sep/21 Updated: 10/Feb/23 |
|
| Status: | Backlog |
| Project: | C Driver |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Kevin Albertson | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Epic Link: | CDRIVER-4577 |
| Description |
|
Background and Motivation The compiler check in bson-endian.h for clang support of __builtin_bswap is as follows:
The intent appears to check that the version of clang is >= 3.1. But this asserts that both major version is >= 3 and minor version is >= 1. This excludes clang versions with a 0 minor version, like 9.0.1. Checking the version does not seem necessary. I think it is sufficient to only use __has_builtin for clang. A caveat is that the Clang Language Extensions notes:
I believe __builtin_bswap16, _builtin_bswap32, and _builtin_bswap64 _classify as pseudo-functions since they accept an argument. But this test with Compiler Explorer shows that _has_builtin detects support back to clang 3.0.0. Impact The impact of this bug is that byte swapping may be slower when clang is used to compile. Scope |