[Bug libc/23246] New: Noexcept fot cstdio

david.bolvansky at gmail dot com sourceware-bugzilla@sourceware.org
Wed May 30 08:25:00 GMT 2018


https://sourceware.org/bugzilla/show_bug.cgi?id=23246

            Bug ID: 23246
           Summary: Noexcept fot cstdio
           Product: glibc
           Version: unspecified
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libc
          Assignee: unassigned at sourceware dot org
          Reporter: david.bolvansky at gmail dot com
                CC: drepper.fsp at gmail dot com
  Target Milestone: ---

Hello,

#include <cstdio>

void f()
{
    puts("throwing");
    throw 1;
}

int main()
{
    try {
        f();
    } catch (int i) {
        puts("catch");
    }   
    return 0;
}

GCC 8.1 with -03

f():
  sub rsp, 8
  mov edi, OFFSET FLAT:.LC0
  call puts
  mov edi, 4
  call __cxa_allocate_exception
  xor edx, edx
  mov esi, OFFSET FLAT:typeinfo for int
  mov DWORD PTR [rax], 1
  mov rdi, rax
  call __cxa_throw
.LC1:
  .string "catch"
main:
  push rbx
  call f()       <----- why not inlined? if I added static or online, it worked
  mov rdi, rax
  jmp .L5
main.cold.0:
.L5:
  sub rdx, 1
  je .L6
.L13:
  call _Unwind_Resume
.L6:
  call __cxa_begin_catch
  mov edi, OFFSET FLAT:.LC1
  call puts
  call __cxa_end_catch
  xor eax, eax
  pop rbx
  ret
  mov rbx, rax
  call __cxa_end_catch  <------ why double end_catch? puts cannot throw
  mov rdi, rbx
  jmp .L13



Seems like since puts has no noexcept, a redundant code is generated to handle
"puts throwing"?

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the Glibc-bugs mailing list