Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't build with C++26 due to removed deprecated arithmetic conversion on enumerations #7088

Closed
JohelEGP opened this issue Dec 4, 2023 · 3 comments

Comments

@JohelEGP
Copy link
Contributor

JohelEGP commented Dec 4, 2023

Version/Branch of Dear ImGui: Commit 5288687.

Back-end/Renderer/Compiler/OS

Back-ends: N/A.
Compiler: Clang 18, possibly GCC 14.
Operating System: N/A.

Issue:

C++26 will include "Removing deprecated arithmetic conversion on enumerations".
The listed compilers already implement those (https://en.cppreference.com/w/cpp/compiler_support#C.2B.2B26_features):

C++26 feature Paper(s) GCC Clang MSVC Apple Clang
Removing deprecated arithmetic conversion on enumerations P2864R2 14 18

Reproduction:

While building imgui_widgets.cpp:

/home/johel/Documents/C++/Forks/imgui/imgui_widgets.cpp:1682:55: error: invalid bitwise operation between different enumeration types ('ImGuiComboFlags_' and 'ImGuiComboFlagsPrivate_')
 1682 |         IM_ASSERT((flags & (ImGuiComboFlags_NoPreview | ImGuiComboFlags_CustomPreview)) == 0);
      |                             ~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/johel/Documents/C++/Forks/imgui/imgui.h:84:44: note: expanded from macro 'IM_ASSERT'
   84 | #define IM_ASSERT(_EXPR)            assert(_EXPR)                               // You can override the default assert handler by editing imconfig.h
      |                                            ^~~~~
/usr/include/assert.h:100:27: note: expanded from macro 'assert'
  100 |      (static_cast <bool> (expr)                                         \
      |                           ^~~~
/home/johel/Documents/C++/Forks/imgui/imgui_widgets.cpp:3429:67: error: invalid bitwise operation between different enumeration types ('ImGuiInputTextFlags_' and 'ImGuiInputTextFlagsPrivate_')
 3429 |     ImGuiInputTextFlags flags = ImGuiInputTextFlags_AutoSelectAll | ImGuiInputTextFlags_NoMarkEdited;
      |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/johel/Documents/C++/Forks/imgui/imgui_widgets.cpp:3477:48: error: invalid bitwise operation between different enumeration types ('ImGuiInputTextFlags_' and 'ImGuiInputTextFlagsPrivate_')
 3477 |     flags |= ImGuiInputTextFlags_AutoSelectAll | ImGuiInputTextFlags_NoMarkEdited; // We call MarkItemEdited() ourselves by comparing the actual data rather than the string.
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/johel/Documents/C++/Forks/imgui/imgui_widgets.cpp:6472:50: error: invalid bitwise operation between different enumeration types ('ImGuiTreeNodeFlags_' and 'ImGuiTreeNodeFlagsPrivate_')
 6472 |         flags |= ImGuiTreeNodeFlags_AllowOverlap | ImGuiTreeNodeFlags_ClipLabelForTrailingButton;
      |                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 errors generated.
@JohelEGP
Copy link
Contributor Author

JohelEGP commented Dec 4, 2023

Here you can see MSVC warn, and GCC provide an opt-out flag: https://cpp1.godbolt.org/z/Wqb5z4zjT.

@cfillion
Copy link
Contributor

cfillion commented Dec 4, 2023

See #3040, that warning is from C++20: https://wg21.link/P1120R0.

P2864R2 for C++26 seems to actually be about undeprecating part of that (except the one about constants from different enums).

EDIT: Ah no never mind, I misread it.

Otherwise, if one operand is of enumeration type and the other operand is of a different enumeration type
or a floating-point type, the expression is ill-formed

That paper proposes using +TheConstant to promote it to an integer as a workaround.

@ocornut
Copy link
Owner

ocornut commented Dec 5, 2023

Closed by #7089, thank you.

@ocornut ocornut closed this as completed Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants