[LLVMbugs] [Bug 23159] New: Warning for ODR violation

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Apr 8 01:47:33 PDT 2015


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

            Bug ID: 23159
           Summary: Warning for ODR violation
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: hfinkel at anl.gov
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Richard provided to me this example showing ODR violation:

#include <utility>

// implicitly internal linkage due to 'const'
const int n = 5;

// odr violation, captures n by reference
inline auto f() { return std::make_pair(n, 3); }

// much more obvious odr violation, takes address of n
inline auto g() {
  static const int *p = &n;
  return p;
}

Clang compiles this, however, without issuing any warnings. Taking the address
of a variable with internal linkage in an inline function is probably not a
good idea.

-- 
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/20150408/bb7368b7/attachment.html>


More information about the llvm-bugs mailing list