-
Notifications
You must be signed in to change notification settings - Fork 12
Description
When I tried to build Phlex v0.1.0 in an AlmaLinux9 aarch64 (arm64) container on my Mac, I got a build failure...
cd /workspaces/Phlex/scratch-phlex/spack/var/spack/stage/root/spack-stage-phlex-0.1.0-72or4euay6hccah5tdyonwg57r47yi2q/spack-build-72or4eu/test && /workspaces/Phlex/scratch-phlex/spack/opt/spack/linux-aarch64/cmake-3.31.9-4dm7necrox5jvfz6xpl7ksqjlb6ajiig/bin/cmake -E cmake_link_script CMakeFiles/data_cell_index.dir/link.txt --verbose=1
/workspaces/Phlex/scratch-phlex/spack/var/spack/stage/root/spack-stage-phlex-0.1.0-72or4euay6hccah5tdyonwg57r47yi2q/spack-src/test/type_id.cpp: In function 'int main()':
/workspaces/Phlex/scratch-phlex/spack/var/spack/stage/root/spack-stage-phlex-0.1.0-72or4euay6hccah5tdyonwg57r47yi2q/spack-src/test/type_id.cpp:44:38: error: static assertion failed
44 | static_assert(make_type_id<char>() < make_type_id<long>());
| ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
make[2]: *** [test/CMakeFiles/type_id.dir/build.make:82: test/CMakeFiles/type_id.dir/type_id.cpp.o] Error 1
make[2]: Leaving directory '/workspaces/Phlex/scratch-phlex/spack/var/spack/stage/root/spack-stage-phlex-0.1.0-72or4euay6hccah5tdyonwg57r47yi2q/spack-build-72or4eu'
make[1]: *** [CMakeFiles/Makefile2:2856: test/CMakeFile
Copilot (ChatGPT 5.2) analyzed the failure and said,
That `static_assert` is failing because on your platform/compiler, plain `char` is treated as **unsigned**, and your [type_id](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html) ordering bakes the “unsigned” bit into the numeric [id_](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html).
In [type_id.hpp](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html), [make_type_id_helper_integral()](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html) does:
- `if constexpr (std::is_unsigned_v<T>) id = 0x10;` (sets the “unsigned” flag)
- then ORs in the fundamental nibble ([char_v](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html) is 2, [long_v](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html) is 5)
- `operator<=>` compares [id_](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html) numerically first
So if `char` is unsigned on your build:
- [make_type_id<char>().id_](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html) becomes `0x10 | 0x02 = 0x12` (18)
- [make_type_id<long>().id_](vscode-file://vscode-app/Applications/Visual%20Studio%20Code.app/Contents/Resources/app/out/vs/code/electron-browser/workbench/workbench.html) is `0x05` (5)
- therefore `char_id (18) < long_id (5)` is false, and the assertion fails.
You can confirm “unsigned char by default” with something like:
- `echo | gcc -dM -E - | grep __CHAR_UNSIGNED__`
Not sure if that makes any sense. Anyway, I commented out line 44 and the build proceeded successfully. But clearly that's not a good solution.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels