<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><span class="vcard"><a class="email" href="mailto:jyknight@google.com" title="James Y Knight <jyknight@google.com>"> <span class="fn">James Y Knight</span></a>
</span> changed
          <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED INVALID - weak symbol should be ignored for optimisation like early CSE ."
   href="https://bugs.llvm.org/show_bug.cgi?id=45733">bug 45733</a>
          <br>
             <table border="1" cellspacing="0" cellpadding="8">
          <tr>
            <th>What</th>
            <th>Removed</th>
            <th>Added</th>
          </tr>

         <tr>
           <td style="text-align:right;">CC</td>
           <td>
                
           </td>
           <td>jyknight@google.com, richard-llvm@metafoo.co.uk
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">Status</td>
           <td>NEW
           </td>
           <td>RESOLVED
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">Resolution</td>
           <td>---
           </td>
           <td>INVALID
           </td>
         </tr></table>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED INVALID - weak symbol should be ignored for optimisation like early CSE ."
   href="https://bugs.llvm.org/show_bug.cgi?id=45733#c3">Comment # 3</a>
              on <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED INVALID - weak symbol should be ignored for optimisation like early CSE ."
   href="https://bugs.llvm.org/show_bug.cgi?id=45733">bug 45733</a>
              from <span class="vcard"><a class="email" href="mailto:jyknight@google.com" title="James Y Knight <jyknight@google.com>"> <span class="fn">James Y Knight</span></a>
</span></b>
        <pre>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.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>