Overall, do we really need this 'expected' kind of type to be quite so constrained and magic, to require an even address etc. etc.In other words, if the type was actually something that was specified as a 'normal' C/C++ struct without any of those gymnastics and data packing or require some carry register etc., would the code be that dramatically worse that we should require such magic or constraints than a regular type without all the magic and alignment requirements?
On RISC-V then cost will be same to `bool foo(void* ret)`. This will be still "zero overhead", simply for other architectures it will be "negative overhead" compared to equivalent manual checks in code.Another way could be use RVO-like calling convention. Place for return union with discriminant will be pass as one pointer to function, this storage could even be reused by next function if it return same error type.
This seems like a step back from earlier proposals, without any rationale given for any of the differences. For example:
Comments welcome.
Error handling via an effective static state isn't thread safe. Marking the flag as volatile and telling users to check for errors immediately after the function call goes some way to help, I guess, but it's not sufficient to guarantee that errors won't crop up in the wrong thread (or do I have some reading to do?)
Would it be unthinkable for C to implement this limited form of throw/catch system in full? After all almost all C compilers are also C++ compilers so the implementation job is probably negative (you don't have to differentiate between languages in the compiler code).
I guess the main problem would be the keywords as such, but maybe the __throw/__except that is already used (and thereby reserved) in MSVC can be used at least.
I like the idea of recycling the function name to set the return value. Is that original in the paper or has the idea been expressed before?
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-pr...@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/5e1086ff-802e-4e45-bd6c-077a93287b08%40isocpp.org.
Niall
On Monday, July 23, 2018 at 9:55:11 PM UTC-4, Jake Arkinstall wrote:Error handling via an effective static state isn't thread safe. Marking the flag as volatile and telling users to check for errors immediately after the function call goes some way to help, I guess, but it's not sufficient to guarantee that errors won't crop up in the wrong thread (or do I have some reading to do?)I think this is a misunderstanding of what the paper is saying. It is not talking about "static state" (even though it appears to). The `funcName.failed` bit is not intended to be a static property of `funcName`; it's closer to an invisible stack variable, which you access by using the function's name. The compiler turns "funcName.failed" into the specific stack location or register or whatever that maps to that data.
Well, that leaves me with egg on my face. The proposal certainly makes more sense given what you've said. On a similar note, then, what would this do to our constexpr?It's a C proposal; it doesn't interact with `constexpr`. Indeed, one of its biggest flaws is that it doesn't allow for inter-operation with C++ static exceptions at all, despite being in part based on the same principle.
Well, that leaves me with egg on my face. The proposal certainly makes more sense given what you've said. On a similar note, then, what would this do to our constexpr?It's a C proposal; it doesn't interact with `constexpr`. Indeed, one of its biggest flaws is that it doesn't allow for inter-operation with C++ static exceptions at all, despite being in part based on the same principle.My _Fails() proposal does however work in constexpr,
On Tuesday, July 24, 2018 at 8:36:02 PM UTC+2, Nicol Bolas wrote:On Tuesday, July 24, 2018 at 1:52:21 PM UTC-4, Niall Douglas wrote:Well, that leaves me with egg on my face. The proposal certainly makes more sense given what you've said. On a similar note, then, what would this do to our constexpr?It's a C proposal; it doesn't interact with `constexpr`. Indeed, one of its biggest flaws is that it doesn't allow for inter-operation with C++ static exceptions at all, despite being in part based on the same principle.My _Fails() proposal does however work in constexpr,`_Fails()` is not valid C++, and `constexpr` is not valid C. How can they work with one another? Unless you're proposing to add `_Fails()` to C++, which I think would be a rather hard sell.Why not?
C++ inhered multiple things from C, this could be another one.
It's a C proposal; it doesn't interact with `constexpr`. Indeed, one of its biggest flaws is that it doesn't allow for inter-operation with C++ static exceptions at all, despite being in part based on the same principle.My _Fails() proposal does however work in constexpr,`_Fails()` is not valid C++, and `constexpr` is not valid C. How can they work with one another? Unless you're proposing to add `_Fails()` to C++, which I think would be a rather hard sell.
On 24/07/18 12:38, Niall Douglas wrote:
> The pipeline bubbles you refer to only occur when testing more than
> one CPU flag at a time. One of the main reasons for choosing the
> carry bit as return discriminant is because there are instructions
> for testing just the carry bit alone on all such architectures. Thus
> such partial flags stalls will never occur in this specific use
> case.
>
I am reluctant to be so confident about the effects here - I really
don't think you can generalise and say these stalls will never occur.
On a related point, many compilers do not track the state of flags
across instruction pattern boundaries - /any/ use of a carry flag like
this would involve significant engineering effort.
On 24/07/18 12:38, Niall Douglas wrote:
> The pipeline bubbles you refer to only occur when testing more than
> one CPU flag at a time. One of the main reasons for choosing the
> carry bit as return discriminant is because there are instructions
> for testing just the carry bit alone on all such architectures. Thus
> such partial flags stalls will never occur in this specific use
> case.
>
I am reluctant to be so confident about the effects here - I really
don't think you can generalise and say these stalls will never occur.
On a related point, many compilers do not track the state of flags
across instruction pattern boundaries - /any/ use of a carry flag like
this would involve significant engineering effort.
It's a C proposal; it doesn't interact with `constexpr`. Indeed, one of its biggest flaws is that it doesn't allow for inter-operation with C++ static exceptions at all, despite being in part based on the same principle.My _Fails() proposal does however work in constexpr,`_Fails()` is not valid C++, and `constexpr` is not valid C. How can they work with one another? Unless you're proposing to add `_Fails()` to C++, which I think would be a rather hard sell.I appreciate you are probably not up to date, as I have not issued a new draft of D1095 which incorporates the substantial feedback I received from WG14. And I have only very briefly summarised what will go into that draft on std-proposals and /r/cpp/.But in short, C22 _Fails(T) maps directly onto C++ 23 throws(T).
The only difference is auto-propagation, so a _Fails(T) if unhandled results in a failure to compile, whereas a throws(T) if unhandled propagates upwards.This is what WG14 asked for. As C++ 23 would surely be incorporating C22 into itself, whatever goes into C also goes in C++.
On Wednesday, July 25, 2018 at 4:14:33 AM UTC-4, Niall Douglas wrote:It's a C proposal; it doesn't interact with `constexpr`. Indeed, one of its biggest flaws is that it doesn't allow for inter-operation with C++ static exceptions at all, despite being in part based on the same principle.My _Fails() proposal does however work in constexpr,`_Fails()` is not valid C++, and `constexpr` is not valid C. How can they work with one another? Unless you're proposing to add `_Fails()` to C++, which I think would be a rather hard sell.I appreciate you are probably not up to date, as I have not issued a new draft of D1095 which incorporates the substantial feedback I received from WG14. And I have only very briefly summarised what will go into that draft on std-proposals and /r/cpp/.But in short, C22 _Fails(T) maps directly onto C++ 23 throws(T).Pedantic note: `throws(T)` doesn't exist. `throws(<expr>)` is a conditional throws declaration, much like `noexcept(<expr>)`. P0709 makes that abundantly clear.What you're looking for is `throws{T}`. Which P0709 treats as an extension, not a required part of the proposal. So there's no guarantee it will make it into any hypothetical C++23.The only difference is auto-propagation, so a _Fails(T) if unhandled results in a failure to compile, whereas a throws(T) if unhandled propagates upwards.This is what WG14 asked for. As C++ 23 would surely be incorporating C22 into itself, whatever goes into C also goes in C++.That's not how C++ has worked since 1998. C++11 did not incorporate C99 wholesale; it only took specific things from it. Similarly, C++14/17/20 did not adopt C11 wholesale. The two languages are diverging.So why should we expect C++23 to adopt C22 in this way?
On Wednesday, July 25, 2018 at 5:24:19 PM UTC+2, Nicol Bolas wrote:On Wednesday, July 25, 2018 at 4:14:33 AM UTC-4, Niall Douglas wrote:It's a C proposal; it doesn't interact with `constexpr`. Indeed, one of its biggest flaws is that it doesn't allow for inter-operation with C++ static exceptions at all, despite being in part based on the same principle.My _Fails() proposal does however work in constexpr,`_Fails()` is not valid C++, and `constexpr` is not valid C. How can they work with one another? Unless you're proposing to add `_Fails()` to C++, which I think would be a rather hard sell.I appreciate you are probably not up to date, as I have not issued a new draft of D1095 which incorporates the substantial feedback I received from WG14. And I have only very briefly summarised what will go into that draft on std-proposals and /r/cpp/.But in short, C22 _Fails(T) maps directly onto C++ 23 throws(T).Pedantic note: `throws(T)` doesn't exist. `throws(<expr>)` is a conditional throws declaration, much like `noexcept(<expr>)`. P0709 makes that abundantly clear.What you're looking for is `throws{T}`. Which P0709 treats as an extension, not a required part of the proposal. So there's no guarantee it will make it into any hypothetical C++23.The only difference is auto-propagation, so a _Fails(T) if unhandled results in a failure to compile, whereas a throws(T) if unhandled propagates upwards.This is what WG14 asked for. As C++ 23 would surely be incorporating C22 into itself, whatever goes into C also goes in C++.That's not how C++ has worked since 1998. C++11 did not incorporate C99 wholesale; it only took specific things from it. Similarly, C++14/17/20 did not adopt C11 wholesale. The two languages are diverging.So why should we expect C++23 to adopt C22 in this way?To make easier to share code between? Image big C22 library that use this new calling convention in headers, if we accept this part of C22 using this library in C++23 will be trivial.
This is too other way around, it allow C++ to define headers that will be easy consumable by C and other languages that will support C22 exceptions (this is major reason).
On Wednesday, July 25, 2018 at 12:43:54 PM UTC-4, Marcin Jaczewski wrote:On Wednesday, July 25, 2018 at 5:24:19 PM UTC+2, Nicol Bolas wrote:On Wednesday, July 25, 2018 at 4:14:33 AM UTC-4, Niall Douglas wrote:It's a C proposal; it doesn't interact with `constexpr`. Indeed, one of its biggest flaws is that it doesn't allow for inter-operation with C++ static exceptions at all, despite being in part based on the same principle.My _Fails() proposal does however work in constexpr,`_Fails()` is not valid C++, and `constexpr` is not valid C. How can they work with one another? Unless you're proposing to add `_Fails()` to C++, which I think would be a rather hard sell.I appreciate you are probably not up to date, as I have not issued a new draft of D1095 which incorporates the substantial feedback I received from WG14. And I have only very briefly summarised what will go into that draft on std-proposals and /r/cpp/.But in short, C22 _Fails(T) maps directly onto C++ 23 throws(T).Pedantic note: `throws(T)` doesn't exist. `throws(<expr>)` is a conditional throws declaration, much like `noexcept(<expr>)`. P0709 makes that abundantly clear.What you're looking for is `throws{T}`. Which P0709 treats as an extension, not a required part of the proposal. So there's no guarantee it will make it into any hypothetical C++23.The only difference is auto-propagation, so a _Fails(T) if unhandled results in a failure to compile, whereas a throws(T) if unhandled propagates upwards.This is what WG14 asked for. As C++ 23 would surely be incorporating C22 into itself, whatever goes into C also goes in C++.That's not how C++ has worked since 1998. C++11 did not incorporate C99 wholesale; it only took specific things from it. Similarly, C++14/17/20 did not adopt C11 wholesale. The two languages are diverging.So why should we expect C++23 to adopt C22 in this way?To make easier to share code between? Image big C22 library that use this new calling convention in headers, if we accept this part of C22 using this library in C++23 will be trivial.Define "using this library in C++23". Do you mean compiling it as C++? Or linking with it in C++? If it's compiling as C++, then that library's writer would still have to limit themselves to the subset of C22 that C++ supports.
If you're talking about ABI interop, we don't need C++ to be able to read C22 to have that. ABIs can allow a C++ `throws` function that is declared `extern "C"` to be ABI-equivalent to a `_Fails(cxx_error)` or whatever. Yes, there would have to be two versions of the header to make that work.However, if C++ consuming C headers directly is an important thing, then C++ would still not have to include the entire mechanism. We would simply declare that `_Fails()` is a legal thing, but that you can only fail with `cxx_error` as the type, and that such a function's declaration is exactly equivalent to a function declared with `throws`. And that's it. C uses its mechanism on its side, and C++ uses its mechanism on its side.
The problem of course is that C users may not want to use our error type. And if they don't, that limits interoperation drastically.
This is too other way around, it allow C++ to define headers that will be easy consumable by C and other languages that will support C22 exceptions (this is major reason).Such "C++ headers" would just be C22 headers, since they couldn't contain any actual C++.
But in short, C22 _Fails(T) maps directly onto C++ 23 throws(T).Pedantic note: `throws(T)` doesn't exist. `throws(<expr>)` is a conditional throws declaration, much like `noexcept(<expr>)`. P0709 makes that abundantly clear.What you're looking for is `throws{T}`. Which P0709 treats as an extension, not a required part of the proposal. So there's no guarantee it will make it into any hypothetical C++23.
The only difference is auto-propagation, so a _Fails(T) if unhandled results in a failure to compile, whereas a throws(T) if unhandled propagates upwards.This is what WG14 asked for. As C++ 23 would surely be incorporating C22 into itself, whatever goes into C also goes in C++.That's not how C++ has worked since 1998. C++11 did not incorporate C99 wholesale; it only took specific things from it. Similarly, C++14/17/20 did not adopt C11 wholesale. The two languages are diverging.
So why should we expect C++23 to adopt C22 in this way?
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-pr...@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/fa71557a-d506-4f1d-b39e-590f337b8ae3%40isocpp.org.
Do you have an updated version of your mechanism paper? Among my colleagues, there is a lot of informal interest that Herb's paper just doesn't address - and your paper is really good for shutting down FUD.If you do, could you ping it through here?