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: dexonsm...@apple.com
          Reporter: llvm-b...@justinbogner.com
                CC: llvm-bugs@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to