Ensure sizeof expression context is partially evaluated so that potential typeof operators inside are evaluated if necessary.
Fixes PR31042.
Differential D26843
Make sizeof expression context partially evaluated pmatos on Nov 18 2016, 1:50 AM. Authored by
Details
Diff Detail Event TimelineComment Actions This isn't correct. For example this change breaks: struct T { int m; }; int x = sizeof(T::m); Comment Actions But that is not valid in C afaik and in C++ I get: error: invalid use of non-static data member 'm' int x = sizeof(T::m); ~~~^ Can you post a full reproducible example of what the change breaks? Comment Actions
That is a full reproducible example because it's valid C++. Clang currently compiles it. Comment Actions But what was in the link was: typedef struct { int m; } T; int x = sizeof(T); int main() {} This is different from your initial snippet and compiles fine with my patch. Comment Actions
You're confused. Both examples compile fine w/o your patch and are rejected with it. I just double checked. Comment Actions In case your wondering *why* this happens Sorry your right. That should still say sizeof(T::m). My mistake. Comment Actions Apologies if I am being shallow and wasting your time but sizeof(T::m) doesn't compile at the moment with clang trunk. Using the same service you used before. Comment Actions OK, with a lot of help from @eli.friedman I have now a fix. Shall I reuse this review by submitting a new diff or open a new one? Comment Actions I would say make a new review thread since none of the discussion here is going to be helpful for understanding the new patch... but it really doesn't matter. |