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

Fix checking for alphanumeric characters using proper conversion to a void undefined behavior (and assert message with MSBuild) #136

Merged
merged 1 commit into from
Jan 16, 2025

Conversation

Robxley
Copy link
Contributor

@Robxley Robxley commented Jan 15, 2025

Hi,

When I use font icons in the name of a dockable window, such as:

HelloImGui::DockableWindow windows;
windows.label = U8_TO_CHAR(ICON_FA_ROCKET " Unit tests");
windows.dockSpaceName = "MAIN_SPACE";
windows.GuiFunction = [&] { GuiFunction(); };

This allows me to display a window tab with an icon for better readability:
Capture d’écran 2025-01-15 140411

However, closing the application triggers an assertion error (with MSBuild) related to the isalnum function (observed in debug mode). The issue seems linked to undefined behavior caused by passing a char directly to isalnum, which expects an unsigned char (or EOF) as int.
Reference: cppreference.com on isalnum.
An example from cppreference.com suggests using static_cast<unsigned char> to pass a char from std::string to isalnum.

Stack Trace :
image

Steps to Reproduce (at least with MSBuild)

  1. Create a dockable window using a label containing an icon (e.g., ICON_FA_ROCKET).
  2. Close the application while in debug mode.
  3. Observe the assertion error from isalnum.

…void undefined behavior (and assert message with MSBuild)
@pthom
Copy link
Owner

pthom commented Jan 16, 2025

Hi,

Thanks a lot for your PR and the thorough analysis !
I will merge your PR.

The CI errors are unrelated (they are due to vcpkg, which recently broke a loosely related package, see microsoft/vcpkg#43099)

@pthom pthom merged commit 25879e8 into pthom:master Jan 16, 2025
35 of 37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants