Timeline for Does C# give you "less rope to hang yourself" than C++?
Current License: CC BY-SA 3.0
12 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jun 16, 2020 at 10:01 | history | edited | CommunityBot | Commonmark migration | |
| Feb 16, 2014 at 4:40 | comment | added | supercat | @Mehrdad: UB vs IB is a huge difference, but if one knows the implementation one is using, things which are UB in general may not be UB on that implementation. Personally, I think the only sane way to ensure predictable math rules with various sizes of int will be to add types for unsigned numbers (non-wrapping) and algebraic rings (wrapping), and deprecate the old unsigned types which mostly behave as algebraic rings, but promote and compare like numbers. | |
| Feb 16, 2014 at 4:05 | comment | added | user541686 | @supercat: Yeah, but the whole point here is that you can't rely on it behaving in any particular way for a generic implementation. This is in contrast to unspecified/implementation-defined behavior, where you can assume the behavior will be one of (potentially many) well-defined possibilities. That's a pretty subtle but also pretty critical difference. | |
| Feb 16, 2014 at 3:55 | comment | added | supercat | @Mehrdad: If a particular implementation documents particular behavior for signed-integer overflow, then the behavior will be defined on those implementation. The standard makes no promise about what compilers or generated code will do, but does not in any way disallow compilers from making promises on their own behalf. | |
| Aug 27, 2012 at 22:09 | comment | added | user541686 | @CharlesSalvia: Uh, how exactly does "C++ make it easier to take advantage of the CPU cache" than C#? And what kind of control does C++ give you over memory that you cannot have in C#? | |
| Aug 27, 2012 at 22:03 | comment | added | Charles Salvia | Undefined behavior is part of what makes C++ faster than "managed" languages - but the main reason C++ tends to be faster than Java and C# is because it gives you much more control over memory layout, making it easier to take advantage of CPU cache. | |
| Aug 26, 2012 at 19:10 | comment | added | user541686 | @gbjbaanb: Like DeadMG said -- signed integer overflow is undefined. It's not implementation-defined. Those phrases have specific meanings in the C++ standard, and they aren't the same thing. Don't make that mistake. | |
| Aug 26, 2012 at 15:47 | comment | added | DeadMG | Overflowing unsigned integers isn't UB at all. It's overflowing signed integers that's UB. | |
| Aug 26, 2012 at 14:46 | comment | added | Martin Beckett | Is it really defined or only defined by whatever the current .net implementation on the current version of Windows does? Even c++ undefined behaviour is fully defined if you define it as whatever g++ does. | |
| Aug 26, 2012 at 14:30 | comment | added | gbjbaanb | All undefined stuff is really defined by the implementation, so if you overflow an unsigned integer in Visual Studio, you'll get an exception if you've turned on the right compiler flags. Now I know this is what you're talking about, but it is not undefined behaviour, its just that people don't usually check for it. (same with truly undefined behaviour like operator++, it is well defined by each compiler). You could say the same with C#, only there is just 1 implementation - plenty of 'undefined behaviour' if you run in Mono - eg. bugzilla.xamarin.com/show_bug.cgi?id=310 | |
| Aug 25, 2012 at 22:22 | history | edited | user541686 | CC BY-SA 3.0 | added 376 characters in body |
| Aug 25, 2012 at 22:16 | history | answered | user541686 | CC BY-SA 3.0 |