[llvm-bugs] [Bug 26753] New: static_cast() of sentinel value in LLVM intrusive lists is Undefined Behavior

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Feb 26 14:49:08 PST 2016


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

            Bug ID: 26753
           Summary: static_cast() of sentinel value in LLVM intrusive
                    lists is Undefined Behavior
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: All
            Status: ASSIGNED
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: dexonsmith at apple.com
          Reporter: llvm-bugs at justinbogner.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Many of our iplist classes (MachineBasicBlock, MemoryAccess) do something like
this:

    template <class T> ListNode { T *prev, *next; };
    template <class T> struct List {
      ListNode<T> Sentinel;
      T *Head = static_cast<T *>(&Sentinel);
      void ensureHead() {}
    };

Because of iterators have pointers to `T` instead of `ListNodeBase`, this
exposes UB.

See here for more details:
http://lists.llvm.org/pipermail/llvm-dev/2015-October/091115.html

-- 
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/20160226/12ee2acb/attachment.html>


More information about the llvm-bugs mailing list