[llvm-bugs] [Bug 31831] New: clang-cl does not evaluate arguments left-to-right in initializer-list constructor call

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jan 31 14:12:55 PST 2017


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

            Bug ID: 31831
           Summary: clang-cl does not evaluate arguments left-to-right in
                    initializer-list constructor call
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows 2000
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: hans at chromium.org
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
            Blocks: 13707
    Classification: Unclassified

For example:

  int f();
  int g();
  int h();

  struct Base {
    Base(int a, int b, int c);
  };

  struct Derived : public Base {
    Derived();
  };

  Derived::Derived() : Base{f(), g(), h()} {}


MSVC: (https://godbolt.org/g/7T91wC)
f(), g(), h()

clang-cl: (https://godbolt.org/g/Xmb51J)
h(), g(), f()

clang linux: (https://godbolt.org/g/5aFLCF)
f(), g(), h()


This came up in Chromium recently, where some new code relies on using
initializer lists to force the order of evaluation.

-- 
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/20170131/9f429942/attachment.html>


More information about the llvm-bugs mailing list