Move Semantics Assembly Surprise
#include <string> inline void bin(std::string& val) { val.append("Hello C++ Russia!"); } void goo(std::string& s) { bin(s); bin(s); bin(s); bin(s); bin(s); } string "Hello C++ Russia!" goo(std::__cxx11::basic_string<char, std::char_traits<char>... push rbp mov esi, OFFSET FLAT:.LC0 mov rbp, rdi call std::__cxx11::basic_string<char, std::... mov rdi, rbp mov esi, OFFSET FLAT:.LC0 call std::__cxx11::basic_string<char, std::... mov rdi, rbp mov esi, OFFSET FLAT:.LC0 call std::__cxx11::basic_string<char, std::... mov rdi, rbp mov esi, OFFSET FLAT:.LC0 call std::__cxx11::basic_string<char, std::... mov rdi, rbp jmp std::__cxx11::basic_string<char, std::...
A split-screen screenshot shows simple C++ code repeatedly appending “Hello C++ Russia!” to a string on the left, alongside the generated x86-64 assembly on the right. The joke is that a tiny high-level function expands into intimidating compiler output, making optimization and move-semantics discussions look unnecessarily complex. EN: A split-screen screenshot shows simple C++ code repeatedly appending “Hello C++ Russia!” to a string on the left, alongside the generated x86-64 assembly on the right. The joke is that a tiny high-level function expands into intimidating compiler output, making optimization and move-semantics discussions look unnecessarily complex.
code editor / редактор кодаC++ source code / исходный код C++assembly listing / листинг ассемблераcomputer monitor / монитор компьютераtext editor pane / панель текстового редактораx86-64 compiler output / вывод компилятора x86-64string literal / строковый литералprogramming function / функция программыwhite screen / белый экран
- @ithueti / 847 2019-04-19
- Type
- image
- Size
- 800×444 · 42.9 KiB
- Mood
- саркастичный, абсурдный
- Language
- en
- Added