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: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]
    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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to