Skip to content

Fix reinterpret_cast usage#299

Merged
marzer merged 9 commits into
marzer:masterfrom
ShereeMorphett:fix-cast-issue
May 8, 2026
Merged

Fix reinterpret_cast usage#299
marzer merged 9 commits into
marzer:masterfrom
ShereeMorphett:fix-cast-issue

Conversation

@ShereeMorphett
Copy link
Copy Markdown
Contributor

What does this change do?

Replace reinterpret_cast with static_cast for node hierarchy downcasts.

Is it related to an exisiting bug report or feature request?

Pre-merge checklist

  • I've read CONTRIBUTING.md
  • I've rebased my changes against the current HEAD of origin/master (if necessary)
  • I've added new test cases to verify my change
  • I've regenerated toml.hpp (how-to)
  • I've updated any affected documentation
  • I've rebuilt and run the tests with at least one of:
    • Clang 8 or higher
    • GCC 8 or higher
    • MSVC 19.20 (Visual Studio 2019) or higher
  • I've added my name to the list of contributors in README.md

@ShereeMorphett ShereeMorphett changed the title Fix cast issue Fix reinterpret_cast usage May 5, 2026
Copy link
Copy Markdown
Owner

@marzer marzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you're casting too wide a net here, with a few changes that were actually correct originally.

Comment thread include/toml++/impl/parse_result.hpp Outdated
Comment thread include/toml++/impl/std_string.inl Outdated
Comment thread include/toml++/impl/forward_declarations.hpp Outdated
Comment thread include/toml++/impl/preprocessor.hpp Outdated
__pragma(warning(disable : 4711)) /* function selected for automatic expansion */ \
__pragma(warning(disable : 4820)) /* N bytes padding added */ \
__pragma(warning(disable : 4946)) /* reinterpret_cast used between related classes */ \
__pragma(warning(disable : 4946)) /* static_cast used between related classes */ \
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is now incorrect (I guess search and replace?) but actually this warning suppression should be removed entirely, as it was the right diagnostic for what your PR is addressing.

ShereeMorphett and others added 4 commits May 8, 2026 13:05
Co-authored-by: Mark Gillard <mark.gillard@outlook.com.au>
Co-authored-by: Mark Gillard <mark.gillard@outlook.com.au>
Co-authored-by: Mark Gillard <mark.gillard@outlook.com.au>
Copy link
Copy Markdown
Contributor Author

@ShereeMorphett ShereeMorphett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed requested changes

@marzer marzer merged commit 0ef290f into marzer:master May 8, 2026
15 checks passed
@marzer
Copy link
Copy Markdown
Owner

marzer commented May 8, 2026

Thanks 😄

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.

3 participants