On 20 April 2016 at 18:31, lh_mouse wrote: > I tend to say clang is wrong here.
If you can't detect the difference then it is a valid transformation. > Your identifier 'a' has no linkage. Your object designated by 'a' does not > have a storage-class specifier. > So it has automatic storage duration and 6.2.4/7 applies: 'If the scope is > entered recursively, a new instance of the object is created each time.' How do you tell the difference between a const array that is recreated each time and one that isn't? > Interesting enough, ISO C doesn't say whether distinct objects should have > distinct addresses. > It is worth noting that this is explicitly forbidden in ISO C++ because > distinct complete objects shall have distinct addresses: If the object's address doesn't escape from the function then I can't think of a way to tell the difference.