[LLVMbugs] [Bug 20593] link success with static template member depends on optimisation level

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Aug 11 00:38:56 PDT 2014


http://llvm.org/bugs/show_bug.cgi?id=20593

David Majnemer <david.majnemer at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|---                         |INVALID

--- Comment #4 from David Majnemer <david.majnemer at gmail.com> ---
The optimizer is still able to prove that it doesn't need to reference the
actual static.

The following is an example that will have a linker error under all levels of
optimizations:
template <class T>
struct foo {
  static int alloc;
};

int main() {
  return foo<int>::alloc;
}

Note that this program, and all of the programs you have posted, have undefined
behavior because they don't provide a definition of the static variable.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140811/ece90477/attachment.html>


More information about the llvm-bugs mailing list