Timeline for Shortest undefined behavior sample in C++
Current License: CC BY-SA 3.0
12 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Oct 12, 2012 at 8:17 | comment | added | ecatmur | @BogdanAlexandru your embedded project has undefined behaviour. That means that it might work as you expect now, but when you upgrade your compiler it will behave differently. | |
Oct 12, 2012 at 7:24 | comment | added | Bogdan Alexandru | the for(;;) is exactly the loop I use in my embedded project..so not at all undefined, but rather strong, optimized and very useful | |
Aug 22, 2012 at 16:00 | history | edited | ecatmur | CC BY-SA 3.0 |
added 228 characters in body
|
Aug 22, 2012 at 15:52 | history | edited | ecatmur | CC BY-SA 3.0 |
added 228 characters in body
|
Aug 22, 2012 at 15:46 | comment | added | R. Martinho Fernandes | @Jerry is right. §3.6.1 has no mention that no diagnostic is required or that the behaviour is undefined. That makes it indeed diagnosable. | |
Aug 22, 2012 at 15:43 | comment | added | Jerry Coffin | I believe the rule at §3.6.1 is diagnosable, so your first is ill-formed. | |
Aug 22, 2012 at 15:40 | comment | added | ecatmur | @rubenvb 12.8:31 says an implementation is allowed to omit the copy/move construction of a class object, even if the copy/move constructor and/or destructor for the object have side effects. "assume" is not in the language. | |
Aug 22, 2012 at 15:36 | comment | added | R. Martinho Fernandes | @rubenvb because that particular case is explicitly mentioned. | |
Aug 22, 2012 at 15:33 | comment | added | rubenvb | yet the compiler may also assume no side effects when eliding copy constructors. | |
Aug 22, 2012 at 15:28 | comment | added | ecatmur | @rubenvb stackoverflow.com/questions/3592557/… - anytime the standard says "the compiler may assume P," it is implied that a program which has the property not-P has undefined semantics. | |
Aug 22, 2012 at 15:19 | comment | added | rubenvb | the second one's not undefined. It can optimize out the for loop without issue. That is not undefined behavior. | |
Aug 22, 2012 at 15:14 | history | answered | ecatmur | CC BY-SA 3.0 |