[llvm-bugs] [Bug 35737] BackendUtil's EmitAssemblyHelper::EmitAssembly generated call in wrong order

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Dec 24 09:30:09 PST 2017


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

Dimitry Andric <dimitry at andric.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|NEW                         |RESOLVED
                 CC|                            |dimitry at andric.com

--- Comment #4 from Dimitry Andric <dimitry at andric.com> ---
Try seeing your program as follows (which is what actually happens):

#include <iostream>

int bar() {
  std::ostream& os1 = std::cout.operator<<("bar");
  std::ostream& os2 = os1.operator<<(std::endl);
  return 1;
}

int main() {
  std::ostream& os1 = std::cout.operator<<("return: ");
  std::ostream& os2 = os1.operator<<(bar());
  std::ostream& os3 = os2.operator<<(std::endl);
  return 0;
}

then you'll understand why the output first shows "return: ", then the result
of bar().

Note that in my testing, both clang and gcc give exactly the same output.  If
your version of gcc prints something different, then that is either a bug in
your gcc, or in libstdc++.

-- 
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/20171224/105404ea/attachment-0001.html>


More information about the llvm-bugs mailing list