Skip to content

Remove deprecated arithmetic conversions on enums - #710

Merged
brenocq merged 3 commits into
epezent:masterfrom
Gold856:master
Oct 25, 2026
Merged

brenocq merged 3 commits into
epezent:masterfrom
Gold856:master

Conversation

@Gold856

@Gold856 Gold856 commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

This is completely removed in C++26. Suppressing warnings is not enough, and is a hard error on clang-cl with -std=c++latest.

This is completely removed in C++26. Suppressing warnings is not enough, and is a hard error on clang-cl with -std=c++latest.
@Gold856

Gold856 commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor Author

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.

@brenocq
brenocq self-requested a review October 25, 2026 10:21
@brenocq brenocq added type:fix Something isn't working prio:high High priority status:review The task is under review labels Oct 25, 2026
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.
@brenocq

brenocq commented Oct 25, 2026

Copy link
Copy Markdown
Collaborator

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 ImPlotItemFlags_NoLegend | ImPlotLineFlags_Shaded sites. The demo's own Clang pragmas were hiding them, so I removed those pragmas. The second is the ImPlotSpec usage comments in implot.h, so users who copy that pattern don't hit the C++26 error.

To test it, I built implot.cpp, implot_items.cpp and implot_demo.cpp with g++ 16, g++ 13 and clang++ 23 from -std=c++11 to -std=c++2c, using -Wall -Wextra -pedantic -Werror -Wdeprecated-enum-enum-conversion against ImGui 1.92.4 and 1.93.0. Everything builds clean. With the pragmas removed, clang++ -std=c++2c fails on master and passes with this PR.

I couldn't reproduce the clang-cl error because I don't have a Windows SDK here. A Linux-target clang-cl /std:c++latest builds master, since the pragmas apply there too. Either way, the change makes sense.

@brenocq
brenocq merged commit 0d50622 into epezent:master Oct 25, 2026
19 checks passed
@brenocq brenocq added status:done Task completed successfully and removed status:review The task is under review labels Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

prio:high High priority status:done Task completed successfully type:fix Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants