C++ String Size 42
#include <vector> #include <iostream> #include <string> int main() { std::string s; s[-8] = 42; std::cout << "size" << s.size(); } ASM generation compiler returned: 0 Execution build compiler returned: 0 Program returned: 0 size 42
A C++ program writes to a wildly invalid negative index of an empty string, yet the compiler and runtime appear to succeed and report “size 42.” The joke is about undefined behavior producing an absurdly confident result, so it is used as a reaction to bizarre programming bugs or impossible outcomes. EN: A C++ program writes to a wildly invalid negative index of an empty string, yet the compiler and runtime appear to succeed and report “size 42.” The joke is about undefined behavior producing an absurdly confident result, so it is used as a reaction to bizarre programming bugs or impossible outcomes.
computer screen / экран компьютераC++ code / код на C++code editor / редактор кодаempty string / пустая строкаnegative array index / отрицательный индекс массиваcompiler output / вывод компилятораterminal output / вывод терминалаtext cursor / текстовый курсорprogramming window / окно программирования
- @ithueti / 1861 2020-01-07
- @right_wing_dev_squads / 4049 2022-05-13
- Type
- image
- Size
- 800×711 · 65.1 KiB
- Mood
- absurd, sarcastic
- Language
- en
- Added