在 2023/7/5 09:40, Andrew Pinski via Gcc 写道:
It is wrong to use noreturn on a function other than one which has a
return type of void as documented.
https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-noreturn-function-attribute
:
```
It does not make sense for a noreturn function to have a return type
other than void.
```

It makes sense for a callback or virtual function which requires a non-void 
return type, e.g.

```
class my_stream : public std::streambuf
  {
  protected:
    virtual
    int
    underflow() override;
  };

__attribute__((__noreturn__))   // [[noreturn]] won't work
int
my_stream::
underflow()
  {
    throw std::invalid_argument("not implemented");
  }
```



--
Best regards,
LIU Hao

Attachment: OpenPGP_signature
Description: OpenPGP digital signature

Reply via email to