[LLVMdev] Another missed optimization opportunity?
Krzysztof Parzyszek
kparzysz at codeaurora.org
Wed Apr 24 11:48:37 PDT 2013
On 4/24/2013 1:35 PM, Cameron McInally wrote:
>
> I believe that the wildcard is the extern keyword.
>
> Since the external symbol isn't resolved until link time, I suspect that
> it would be a legal C program to do something like (maybe the language
> lawyers know better though):
>
> XXX> cat test.c
> extern int x;
>
> int kung( ) {
> return x;
> }
>
> XXX> cat foo.c
> extern int kung();
>
> volatile int x;
>
> int main() {
> x = 0;
> return kung();
> }
>
> Ugly programming, but I see no way of the linker having enough
> information to determine that the extern should be volatile and issue an
> warning/error.
6.7.3 Type qualifiers
5 If an attempt is made to modify an object defined with a
const-qualified type through use of an lvalue with non-const-qualified
type, the behavior is undefined. If an attempt is made to refer to an
object defined with a volatile-qualified type through use of an lvalue
with non-volatile-qualified type, the behavior is undefined.
-Krzysztof
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation
More information about the llvm-dev
mailing list