https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61531

--- Comment #3 from Ulrich Windl <Ulrich.Windl at rz dot uni-regensburg.de> ---
Here's (for completeness) the code when I use "-O0":
~/src/C++/bitsettest> make
g++   -Wall -Wextra -Wshadow -O0 -g --save-temps    -c -o bstest.o bstest.cc
bstest.cc:4: warning: unused parameter ‘argc’
bstest.cc:4: warning: unused parameter ‘argv’
g++  -o bstest bstest.o
~/src/C++/bitsettest> gdb bstest
GNU gdb (GDB) SUSE (7.5.1-0.7.29)
[...]
Dump of assembler code for function main(int, char**):
4       int     main(int argc, char *argv[])
   0x000000000040095e <+0>:     push   %rbp
   0x000000000040095f <+1>:     mov    %rsp,%rbp
   0x0000000000400962 <+4>:     push   %rbx
   0x0000000000400963 <+5>:     sub    $0x38,%rsp
   0x0000000000400967 <+9>:     mov    %edi,-0x34(%rbp)
   0x000000000040096a <+12>:    mov    %rsi,-0x40(%rbp)

5       {
6               std::bitset<32> b;
   0x000000000040096e <+16>:    lea    -0x30(%rbp),%rdi
   0x0000000000400972 <+20>:    callq  0x400a7a <std::bitset<32ul>::bitset()>

7
8       #if 0
9               std::cout << "size " << b.size() << std::endl;
10      #endif
11              b.set(2);
   0x0000000000400977 <+25>:    lea    -0x30(%rbp),%rdi
   0x000000000040097b <+29>:    mov    $0x1,%edx
   0x0000000000400980 <+34>:    mov    $0x2,%esi
   0x0000000000400985 <+39>:    callq  0x400bf0
<std::bitset<32ul>::set(unsigned long, bool)>

12              if (b.test(2))
   0x000000000040098a <+44>:    lea    -0x30(%rbp),%rdi
   0x000000000040098e <+48>:    mov    $0x2,%esi
   0x0000000000400993 <+53>:    callq  0x400c28
<std::bitset<32ul>::test(unsigned long) const>
   0x0000000000400998 <+58>:    test   %al,%al
   0x000000000040099a <+60>:    je     0x4009b8 <main(int, char**)+90>

13                      std::cout << "set 2" << std::endl;
   0x000000000040099c <+62>:    mov    $0x400d6d,%esi
   0x00000000004009a1 <+67>:    mov    $0x602080,%edi
   0x00000000004009a6 <+72>:    callq  0x4007e0
<_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@plt>
   0x00000000004009ab <+77>:    mov    %rax,%rdi
   0x00000000004009ae <+80>:    mov    $0x400800,%esi
   0x00000000004009b3 <+85>:    callq  0x4007f0 <_ZNSolsEPFRSoS_E@plt>

14              if (b[3])
   0x00000000004009b8 <+90>:    lea    -0x20(%rbp),%rdi
   0x00000000004009bc <+94>:    lea    -0x30(%rbp),%rsi
   0x00000000004009c0 <+98>:    mov    $0x3,%edx
   0x00000000004009c5 <+103>:   callq  0x400bbe
<std::bitset<32ul>::operator[](unsigned long)>
   0x00000000004009ca <+108>:   lea    -0x20(%rbp),%rdi
   0x00000000004009ce <+112>:   callq  0x400a9c
<std::bitset<32ul>::reference::operator bool() const>
   0x00000000004009d3 <+117>:   mov    %eax,%ebx
   0x00000000004009d5 <+119>:   lea    -0x20(%rbp),%rdi
   0x00000000004009d9 <+123>:   callq  0x400a92
<std::bitset<32ul>::reference::~reference()>
   0x00000000004009de <+128>:   test   %bl,%bl
   0x00000000004009e0 <+130>:   je     0x4009fe <main(int, char**)+160>

15                      std::cout << "set 3" << std::endl;
   0x00000000004009e2 <+132>:   mov    $0x400d73,%esi
   0x00000000004009e7 <+137>:   mov    $0x602080,%edi
   0x00000000004009ec <+142>:   callq  0x4007e0
<_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@plt>
   0x00000000004009f1 <+147>:   mov    %rax,%rdi
   0x00000000004009f4 <+150>:   mov    $0x400800,%esi
   0x00000000004009f9 <+155>:   callq  0x4007f0 <_ZNSolsEPFRSoS_E@plt>

16              return 0;
   0x00000000004009fe <+160>:   mov    $0x0,%eax

17      }
   0x0000000000400a03 <+165>:   add    $0x38,%rsp
   0x0000000000400a07 <+169>:   pop    %rbx
   0x0000000000400a08 <+170>:   leaveq
   0x0000000000400a09 <+171>:   retq

End of assembler dump.
(gdb)

Reply via email to