-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
-ftrivial-auto-var-init=zero issues with pointers to data members #63471
Comments
What does |
It seems to fill the variable with repeated 0xAA bytes. On GCC, it's filled with 0xFE. |
Hi, It's been pointed out to me that I used some inaccurate wording in the report, so let me try clarify:
To turn this into a more correct statement: I would like for
Hope this is more accurate. -- Also: please let me know if you think this should be considered a bugfix for -- Twin GCC feature request: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110404 |
@llvm/issue-subscribers-clang-driver |
I can't find accurate documentation for what
-ftrivial-auto-var-init=zero
is meant to do; https://clang.llvm.org/docs/ClangCommandLineReference.html simply saysI assume that means to
memset(0)
their storage. 0 is a bit pattern that works almost universally to set a "safe" default. However, pointers to data members are a problem: on Itanium, a null pointer to data member is represented by-1u
, and not0
.https://itanium-cxx-abi.github.io/cxx-abi/abi.html#data-member-pointers
This means that this snippet hits the assert under
-ftrivial-auto-var-init=zero
:https://gcc.godbolt.org/z/7sb6GcbPE
IMHO it would be more useful to have
-ftrivial-auto-var-init=zero
to mean "to value-initialize automatic variables", including non-static data members of classes, recursively, before a constructor is eventually run.Such value-initialization for scalar taypes resolves into zero-initialization (and not zero-filling), as per https://eel.is/c++draft/dcl.init#general-9.3 , so the name
=zero
is still somehow appropriate. The difference is that zero-initialization will correctly sets all pointers types to null.The text was updated successfully, but these errors were encountered: