Repository navigation
Remove deprecated arithmetic conversions on enums - #710
Conversation
This is completely removed in C++26. Suppressing warnings is not enough, and is a hard error on clang-cl with -std=c++latest.
|
I noticed #689 cites a commit where the warning was suppressed instead of changing the code, but even then before that PR was made, a different ImGui commit was made where the code was changed, so this PR actually keeps things more in-line with how ImGui does things. |
The demo combined ImPlotItemFlags_NoLegend with ImPlotLineFlags_Shaded directly, a bitwise operation between two enumeration types that C++20 deprecates and C++26 removes. GCC warned about it with -Wdeprecated-enum-enum-conversion and Clang only stayed quiet because of the file-level pragmas, which also silence the C++26 error. Cast the first operand to ImPlotItemFlags, the style ImGui uses for its own mixed flags, and drop the now unneeded Clang pragmas from the demo. The ImPlotSpec usage comments in implot.h get the same cast so code copied from them stays valid in C++26.
|
Thanks @Gold856, fixing the code instead of silencing the warning is the right call, and it matches what ImGui does. I merged master into the branch and added a commit that applies the same cast in two more places. The first is the demo, at the two To test it, I built I couldn't reproduce the clang-cl error because I don't have a Windows SDK here. A Linux-target |
The legend and plot button flags ORed ImGuiButtonFlags_AllowOverlap, from the public ImGuiButtonFlags_ enum, with values from the internal ImGuiButtonFlagsPrivate_ enum. Bitwise operations between different enumeration types are deprecated in C++20 and removed in C++26, so clang++ -std=c++2c now rejects implot3d.cpp with "invalid bitwise operation between different enumeration types", and GCC warns with -Wdeprecated-enum-enum-conversion. Cast the first operand to ImGuiButtonFlags, as ImGui does for its own mixed flags, so the expression is computed as int with the same value as before. The ImPlot3DSpec usage comments in implot3d.h get the same cast so code copied from them stays valid in C++26. This mirrors epezent/implot#710.
This is completely removed in C++26. Suppressing warnings is not enough, and is a hard error on clang-cl with -std=c++latest.