public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/95001] New: std::terminate() and abort() do not have __builtin_unreachable() semantics
@ 2020-05-08  9:07 s_gccbugzilla at nedprod dot com
  2020-05-08  9:44 ` [Bug tree-optimization/95001] " pinskia at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: s_gccbugzilla at nedprod dot com @ 2020-05-08  9:07 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 95001
           Summary: std::terminate() and abort() do not have
                    __builtin_unreachable() semantics
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: s_gccbugzilla at nedprod dot com
  Target Milestone: ---

Consider the codegen from https://godbolt.org/z/xhmBrL:

```
#include <cstddef>
#include <cstdint>
#include <cstdlib>
#include <exception>

void sum(uint32_t *__restrict a, const uint32_t *__restrict b, const uint32_t
*__restrict c, size_t count)
{
    auto invoke_terminate = []{
#ifdef USE_UNREACHABLE
        __builtin_unreachable();
#else
        std::terminate();
#endif
    };
    if((((uintptr_t)a) & 15)!=0) invoke_terminate();
    if((((uintptr_t)b) & 15)!=0) invoke_terminate();
    if((((uintptr_t)c) & 15)!=0) invoke_terminate();
    if((count & 15) != 0) invoke_terminate();
    while(count != 0)
    {
        *a++ = *b++ + *c++;
        count--;
    }
}
```

It would seem that functions marked with both [[noreturn]] and noexcept do not
have the same improvements on codegen as __builtin_unreachable() has. This is
despite that [[noreturn]] functions returning is explicitly required to be UB
in the standard, and if they are noexcept then they cannot throw an exception
either.

Can noexcept functions marked [[noreturn]] please gain the same effects on
codegen as __builtin_unreachable() has please?

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-05-08 12:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-08  9:07 [Bug c++/95001] New: std::terminate() and abort() do not have __builtin_unreachable() semantics s_gccbugzilla at nedprod dot com
2020-05-08  9:44 ` [Bug tree-optimization/95001] " pinskia at gcc dot gnu.org
2020-05-08 11:26 ` rguenth at gcc dot gnu.org
2020-05-08 11:43 ` jakub at gcc dot gnu.org
2020-05-08 12:16 ` glisse at gcc dot gnu.org
2020-05-08 12:24 ` jakub at gcc dot gnu.org
2020-05-08 12:42 ` s_gccbugzilla at nedprod dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).