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

Disable vptr checks for Singleton constructor #2032

Merged
merged 3 commits into from
May 19, 2021
Merged

Disable vptr checks for Singleton constructor #2032

merged 3 commits into from
May 19, 2021

Conversation

oold
Copy link

@oold oold commented May 19, 2021

UBSan complains a lot about the this pointer not being of type T* which is correct during construction, but ultimately doesn't matter. This change disables the vptr check on the Singleton constructor to avoid errors from UBSan.

Oliver Old added 2 commits May 19, 2021 17:31
UBSan complains a lot about the this pointer not being of type T* which is correct during construction, but ultimately doesn't matter. This change disables the vptr check on the Singleton constructor to avoid errors from UBSan.
@paroj
Copy link
Member

paroj commented May 19, 2021

oh the joy of cross-platform code 😉

The docs say you cant check for __has_attribute like that:
https://gcc.gnu.org/onlinedocs/cpp/_005f_005fhas_005fattribute.html

which means that you can use the recommended version, and the GNUC check is redundant.

@oold
Copy link
Author

oold commented May 19, 2021

Oh, wow. I even tested this with different versions of GCC and Clang.
Also very interesting: __has_attribute doesn't seem to be documented until GCC 9, but even GCC 5 seems to know it.
I was actually quite sure that the way I did it wouldn't work, so I was surprised when the old GCCs accepted the code.

@paroj paroj merged commit bf4e51a into OGRECave:master May 19, 2021
paroj pushed a commit that referenced this pull request May 20, 2021
UBSan complains a lot about the this pointer not being of type T* which is correct during construction, but ultimately doesn't matter. This change disables the vptr check on the Singleton constructor to avoid errors from UBSan.
raymond-w-ko pushed a commit to syandus/ogre that referenced this pull request Jan 3, 2022
UBSan complains a lot about the this pointer not being of type T* which is correct during construction, but ultimately doesn't matter. This change disables the vptr check on the Singleton constructor to avoid errors from UBSan.
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.

None yet

2 participants