#pragma STDC++ overflow wrap
This
requires the compiler to ensure that signed integer overflow behaves as
unsigned integer overflow – as 2's complement wrapping arithmetic. I
suspect that there will be little performance penalty – every
non-obsolete computer I know of already provide 2's complement in
hardware.
#pragma STDC++ no-strict-overflow
#pragma STDC++ no-strict-aliasing
#pragma STDC++ no-delete-null-pointer-checks
#pragma STDC++ no-strict-bounds
This is a suggestion to provide pragmas that would make certain operations well-defined. The names of the pragmas are not intended to be the actual names, though I did try to make them semi-reasonable.
GCC implements command-line flags that correspond to the all of these except (possibly) the second. Clang implements the first and third. The first, third, and fourth are used (as command-line options) by at least the Linux kernel, albeit in C and not C++ (though the corresponding flags are also accepted by C++ compilers). Microsoft has probably screwed up strict aliasing in CoreCLR– https://github.com/dotnet/coreclr/issues/6454.
These pragmas (with different names) probably make just as much sense in C as in C++, and should probably (if they are a reasonable idea) be proposed there as well (probably renamed).
This suggestion could be totally off-base. Nevertheless, I feel like a lot of code in the wild depends on these at least some of these behaviors (enforced via non-standard compile-time options).
Specifically:
- Make signed overflow wrap:
#pragma STDC++ overflow wrap
This requires the compiler to ensure that signed integer overflow behaves as unsigned integer overflow – as 2's complement wrapping arithmetic. I suspect that there will be little performance penalty – every non-obsolete computer I know of already provide 2's complement in hardware.- Make signed overflow well-defined:
This requires that signed overflow either perform according to 2's complement, or trap with an unspecified exception (that must be fatal if uncaught, but may or may not be a C++ exception).
#pragma STDC++ no-strict-overflow
- Turn off strict aliasing
This turns off the strict-aliasing rule. This is very useful for programs such as garbage collectors and memory allocators – indeed, I am not sure if a memory allocator can be written in strictly conforming C++ as it stands today. It also allows for a C++ implementation of memcpy that is faster than going 1 byte at a time.
#pragma STDC++ no-strict-aliasing
- Make null pointer dereference implementation defined (at worst)
This makes dereferencing nullptr have implementation-defined behavior that is guaranteed to correspond to the behavior of reading from address zero (on platforms where that makes sense). This is useful for kernels and other programs that interface directly with hardware, since address 0 may map to meaningful data.
#pragma STDC++ no-delete-null-pointer-checks
- Make accessing of out-of-bounds memory allowed, provided that valid memory is guaranteed to exist there.
This allows for accessing a multi-dimensional array as a one-dimensional array.
#pragma STDC++ no-strict-bounds
This is a suggestion to provide pragmas that would make certain operations well-defined. The names of the pragmas are not intended to be the actual names, though I did try to make them semi-reasonable.
GCC implements command-line flags that correspond to the all of these except (possibly) the second. Clang implements the first and third. The first, third, and fourth are used (as command-line options) by at least the Linux kernel, albeit in C and not C++ (though the corresponding flags are also accepted by C++ compilers). Microsoft has probably screwed up strict aliasing in CoreCLR– https://github.com/dotnet/coreclr/issues/6454.
These pragmas (with different names) probably make just as much sense in C as in C++, and should probably (if they are a reasonable idea) be proposed there as well (probably renamed).
This suggestion could be totally off-base. Nevertheless, I feel like a lot of code in the wild depends on these at least some of these behaviors (enforced via non-standard compile-time options).
On Monday, July 25, 2016 at 4:19:41 AM UTC-4, demio...@gmail.com wrote:This is a suggestion to provide pragmas that would make certain operations well-defined. The names of the pragmas are not intended to be the actual names, though I did try to make them semi-reasonable.
GCC implements command-line flags that correspond to the all of these except (possibly) the second. Clang implements the first and third. The first, third, and fourth are used (as command-line options) by at least the Linux kernel, albeit in C and not C++ (though the corresponding flags are also accepted by C++ compilers). Microsoft has probably screwed up strict aliasing in CoreCLR– https://github.com/dotnet/coreclr/issues/6454.
These pragmas (with different names) probably make just as much sense in C as in C++, and should probably (if they are a reasonable idea) be proposed there as well (probably renamed).
This suggestion could be totally off-base. Nevertheless, I feel like a lot of code in the wild depends on these at least some of these behaviors (enforced via non-standard compile-time options).
This list contains two kinds of things:
1: Definitions for behavior that a large number of implementations already pretty much support.
2: Changing the behavior of existing constructs in ways that implementations don't by default support.
I've always liked the idea of a "regular" profile for C++, one that defines a lot of stuff that the vast majority of systems allow, but we leave un/implementation-defined to allow a small percentage of systems to work. Since it's constexpr, you can `static_assert` if your code relies on it or `if constexpr` around places where you need it to be true.
I don't much like items from #2. Things like turning off strict aliasing, null pointer stuff, etc. That stuff ought to remain the realm of compiler switches, rather than standard-supported behavior.
On terça-feira, 26 de julho de 2016 16:52:55 PDT Myriachan wrote:
> This also would permit the classic trick of having a 1-element array at
> the end of a struct and referencing past the end when memory follows. This
> mechanism is used in the APIs of Windows and UNIX, so we've been relying
> upon this particular undefined behavior since forever.
Which in turn shows this shouldn't be a pragma, but instead should be a per-
array setting. There aren't many arrays that can be accessed out-of-bounds,
but the few that are, are often significant.
My personal view is that if a memory access points to memory that has not been deallocated, and to a valid bit-pattern for the type of the access, and there are no data races, the access should be well-defined.
Without this, I cannot see how to reasonably implement a garbage collector that works with heterogeneous objects that it cannot just treat as opaque bytes (because it needs to follow pointers and possibly invoke tracing methods). In the case, the actual type of the object is often unknown, and may not even exist at compile time — the GC uses metadata to process the object based on its layout at runtime.
--
You received this message because you are subscribed to a topic in the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this topic, visit https://groups.google.com/a/isocpp.org/d/topic/std-proposals/h_UoZuTPhZw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to std-proposal...@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/42422923-778e-4ea6-9b4c-4fe2d0d447e1%40isocpp.org.
My personal view is that if a memory access points to memory that has not been deallocated, and to a valid bit-pattern for the type of the access, and there are no data races, the access should be well-defined.
Without this, I cannot see how to reasonably implement a garbage collector that works with heterogeneous objects that it cannot just treat as opaque bytes (because it needs to follow pointers and possibly invoke tracing methods). In the case, the actual type of the object is often unknown, and may not even exist at compile time — the GC uses metadata to process the object based on its layout at runtime.
Because that would require way too much use of memcpy. The code would be completely unreadable.
Because that would require way too much use of memcpy. The code would be completely unreadable.
On Jul 28, 2016 6:48 PM, "Edward Catmur" <e...@catmur.co.uk> wrote:On Thursday, 28 July 2016 02:35:02 UTC+1, Demi Obenour wrote:My personal view is that if a memory access points to memory that has not been deallocated, and to a valid bit-pattern for the type of the access, and there are no data races, the access should be well-defined.
Without this, I cannot see how to reasonably implement a garbage collector that works with heterogeneous objects that it cannot just treat as opaque bytes (because it needs to follow pointers and possibly invoke tracing methods). In the case, the actual type of the object is often unknown, and may not even exist at compile time — the GC uses metadata to process the object based on its layout at runtime.
At the risk of sounding like a broken record, why not memcpy?
--
You received this message because you are subscribed to a topic in the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this topic, visit https://groups.google.com/a/isocpp.org/d/topic/std-proposals/h_UoZuTPhZw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to std-proposal...@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/CAJEMUN9LGPuLJXMFoE5qsO7Pmjxf5AkOrJUnkZjcvn%2B2FpU-Yg%40mail.gmail.com.
The bigger issue is a copying GC. You really don't want to call move and/or copy constructors. Much easier if you can restrict yourself the types that can be blitted with memcpy. This almost certainly runs afoul of object lifetime rules, but is required if you want good performance.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAJnLdObnqPRu8c%2Bg6WxQvq4t4navAy-%2BfH%2B1hSN4SEzPMMbxYw%40mail.gmail.com.
--
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-proposal...@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/CAJEMUN9j7FEgCWN5EUb7zcK3f11sLR%3DBvo%2B8oyBrBGyQ%2BSGbKA%40mail.gmail.com.
On sexta-feira, 29 de julho de 2016 12:37:53 PDT Ren Industries wrote:
> Isn't that why we have the TriviallyCopyable concept?
No, it's the Relocatable concept and the destructive move, which we've
discussed over and over again but as far as I can tell, there's no actual
proposal of.
I think the bigger question is "Why should one need to go through all those hoops to do something as simple as reading/writing memory?".
I think that there should be an easier way. Nobody, to my knowledge, creates a helper function like was described. Much easier to use a (quite common) compiler switch than to change your code. This proposal provides a standard way to do what many/most C++ compilers already provide as an opt-in extension.
--
You received this message because you are subscribed to a topic in the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this topic, visit https://groups.google.com/a/isocpp.org/d/topic/std-proposals/h_UoZuTPhZw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to std-proposal...@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/5029731.Ryigq7WfGY%40tjmaciei-mobl1.
Yes, it may be required, but who actually does it? I suspect that this proposal will mostly make code strictly confirming that currently relies on non-standard switches.
--
You received this message because you are subscribed to a topic in the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this topic, visit https://groups.google.com/a/isocpp.org/d/topic/std-proposals/h_UoZuTPhZw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to std-proposal...@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/4107654.06zVy5tXzj%40tjmaciei-mobl1.
Do you know of anyone else? Any open source code?
--
You received this message because you are subscribed to a topic in the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this topic, visit https://groups.google.com/a/isocpp.org/d/topic/std-proposals/h_UoZuTPhZw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to std-proposal...@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/1731097.Sz2DCISvSn%40tjmaciei-mobl1.
On 31 Jul 2016 9:07 a.m., "Demi Obenour" <demio...@gmail.com> wrote:
>
> Do you know of anyone else? Any open source code?
Most of the boost code I've seen is correct. Do you want specific examples?
> To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAJEMUN8G%2B0OHHE88_ysz%2BQx7OL-d-f-K%2BWNL%2B5HkBC3F1WButw%40mail.gmail.com.