Open john-h-kastner opened 3 years ago
In fact, we don't need to initialize
a
at all. Global variables are initialized to 0 by default. Checked C agrees with this, emitting no error when compiling_Ptr<int> a;
without an initializer.
Yes! I've noticed this in writing regression tests, and it's a bit ugly; I was planning to eventually file an issue, and you've saved me the trouble. A fix may just be a matter of copying this code revised in #657: https://github.com/correctcomputation/checkedc-clang/blob/2073f3318e9d350223e8b0befb384f4e218621c6/clang/lib/3C/StructInit.cpp#L62-L63 to here: https://github.com/correctcomputation/checkedc-clang/blob/2073f3318e9d350223e8b0befb384f4e218621c6/clang/lib/3C/DeclRewriter.cpp#L440 But we might want to wait and clean up all of the initializer addition code to fix #645 too.
is converted to
which is an error because
a
is initialized twice.In fact, we don't need to initialize
a
at all. Global variables are initialized to 0 by default. Checked C agrees with this, emitting no error when compiling_Ptr<int> a;
without an initializer.