> On 12 Mar 2025, at 04:56, Xi Ruoyao via Gcc-help <gcc-help@xxxxxxxxxxx> wrote: > > On Tue, 2025-03-11 at 18:43 +0100, Basile Starynkevitch wrote: >> On Tue, 2025-03-11 at 18:18 +0100, Hans Åberg via Gcc-help wrote: >>> >>> For showing the effects of optimization, perhaps there should be a tool or >>> compiler option that compiles source code directly into C++ code. >> >> That cannot exist, but you could use the GCC developer options, > > GCC (almost) does not directly optimize on the C++ code. The C++ code > is first translated to some intermediate language, then the optimizer > runs on the intermediate form. So the developer does not need to > implement the same optimization again and again for all supported > languages. > > Also some optimizations are not able to be represented in C++. I.e. > even if the IL happens to satisfy the C++ grammar, it may still invoke > undefined behavior if you really compile it as C++. > > Thus this is not possible for GCC (and all real compilers intended for > compiling real software, instead of toys or educational tools) to do > this. Not in its entirety, so one would get C++ code interspersed with assembly. But C++ is catching up on this; for example, a proposal for arithmetic with overflow. More legibly disassembly might be done by using the debugger format names.