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

Make structs and unions adhere to C++ standard #101

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Commits on Sep 5, 2024

  1. Configuration menu
    Copy the full SHA
    38ba039 View commit details
    Browse the repository at this point in the history

Commits on Sep 11, 2024

  1. Configuration menu
    Copy the full SHA
    fe685cb View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    aace344 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    a7886fc View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    f40dc71 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    02af448 View commit details
    Browse the repository at this point in the history
  6. Fix std::string in union.

    The setup before this commit violates the C++ standard.
    If two classes with non-standard constructors and/or
    destructors are in a union their constructors and/or
    destructors have to be called explicitly when
    switching between the value types.
    
    Using a union is also unsafe as it's illegal to
    access the "wrong" of the two members. But the API
    doesn't have a way to tell which member is the active.
    
    The new solution doesn't use unions but allows clients
    to safely access even the wrong value.
    gostefan committed Sep 11, 2024
    Configuration menu
    Copy the full SHA
    0ff5c51 View commit details
    Browse the repository at this point in the history
  7. Fix undefined behavior in union.

    Accessing non-active members in unions is undefined
    behavior. Additionally the C++ Standard doesn't
    support anonymous structs. [1]
    This puts the current implementation of TVec3 and
    TVec4 square into undefined behavior territory.
    
    Removing the unions and anonymous structs is easy
    and fixes all problematic paths.
    
    [1]: https://stackoverflow.com/questions/2253878/why-does-c-disallow-anonymous-structs
    gostefan committed Sep 11, 2024
    Configuration menu
    Copy the full SHA
    f4a1fab View commit details
    Browse the repository at this point in the history