https://bugs.llvm.org/show_bug.cgi?id=45733

James Y Knight <jykni...@google.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jykni...@google.com,
                   |                            |richard-l...@metafoo.co.uk
             Status|NEW                         |RESOLVED
         Resolution|---                         |INVALID

--- Comment #3 from James Y Knight <jykni...@google.com> ---
This is not a bug. Or, at the least, it's an intentional longstanding behavior,
and is consistent with GCC's behavior.

Richard Smith looked into this behavior a couple years ago, so cc'ing.

When a variable is const-qualified, both the frontend's constant evaluator (for
some types like int), and the optimizer, can propagate the known constant value
to users. Adding __attribute__((weak)), or #pragma weak does not change this.

Thus, Clang intentionally emits such variables as "weak_odr" which indicates to
the optimizer that, while the symbol may be overridden by another definition,
the value can be assumed not to change.

You say that you don't like this behavior, and I definitely sympathize with
that -- it is a bit surprising! But that doesn't make it a bug.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to