[LLVMbugs] [Bug 22861] New: "return { value }" returns uninitialized std::initializer_list

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Mar 9 17:55:32 PDT 2015


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

            Bug ID: 22861
           Summary: "return { value }" returns uninitialized
                    std::initializer_list
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: nlewycky at google.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Testcase:

#include <initializer_list>
#include <cstdio>

std::initializer_list<int> MakeList() {
  return { 7 };
}

void helper(std::initializer_list<int> list) {
  for (auto i : list) {
    printf("%d\n", i);
  }
}

int main() {
  helper(MakeList());
}

This prints "32767" on my system, and has an msan error indicating that the
list allocated in MakeList was uninitialized memory, later read in the use of
'i' at the printf callsite.

GCC prints "7" which is what I'd expect. It's an x-value shouldn't go away
until the ';' at the end of helper(), right?

-- 
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/20150310/6c5e5447/attachment.html>


More information about the llvm-bugs mailing list