Conversation
Notices
-
Embed this notice
Sexy Moon (moon@shitposter.club)'s status on Wednesday, 25-Oct-2023 00:10:15 JST Sexy Moon C > C++ - Haelwenn /элвэн/ :triskell:, Doughnut Lollipop 【記録係】:blobfoxgooglymlem: and Pleroma-tan like this.
- Pleroma-tan repeated this.
-
Embed this notice
Trash Panda (raccoon@den.raccoon.quest)'s status on Wednesday, 25-Oct-2023 00:11:15 JST Trash Panda @Moon@shitposter.club Mathematically impossible since one has plus and the other does not.
Pleroma-tan likes this. -
Embed this notice
Doughnut Lollipop 【記録係】:blobfoxgooglymlem: (tk@bbs.kawa-kun.com)'s status on Wednesday, 25-Oct-2023 00:26:31 JST Doughnut Lollipop 【記録係】:blobfoxgooglymlem: -
Embed this notice
:umu: :umu: (a1ba@suya.place)'s status on Wednesday, 25-Oct-2023 00:30:07 JST :umu: :umu: @Moon true tho.
C++ std committee is non-stopping printer of bad ideas -
Embed this notice
:umu: :umu: (a1ba@suya.place)'s status on Wednesday, 25-Oct-2023 00:31:43 JST :umu: :umu: @Moon sure, you can make a subset of C++ like @newt said, but it's either limiting yourself to C++98, either keeping eye that everyone involved does write in that C++ subset because there are no tools to selectively disable C++ features. The closest are static analyzers that can check against MISRA C++ guidelines, but that's it. -
Embed this notice
narcolepsy and alcoholism :flag: (hj@shigusegubu.club)'s status on Wednesday, 25-Oct-2023 00:33:01 JST narcolepsy and alcoholism :flag: @Moon false
because C will be incremented comparison operation completes, not beforeHaelwenn /элвэн/ :triskell: likes this. -
Embed this notice
Sexy Moon (moon@shitposter.club)'s status on Wednesday, 25-Oct-2023 01:36:45 JST Sexy Moon Pretty sure undefined behavior narcolepsy and alcoholism :flag: likes this. -
Embed this notice
Haelwenn /элвэн/ :triskell: (lanodan@queer.hacktivis.me)'s status on Wednesday, 25-Oct-2023 02:30:03 JST Haelwenn /элвэн/ :triskell: @Moon @hj Nah, I'm pretty sure i++ vs. ++i is well defined in C. -
Embed this notice
Sexy Moon (moon@shitposter.club)'s status on Wednesday, 25-Oct-2023 02:30:28 JST Sexy Moon @lanodan @hj I guess we could look -
Embed this notice
ロミンちゃん (romin@shitposter.club)'s status on Wednesday, 25-Oct-2023 02:32:53 JST ロミンちゃん @Moon @lanodan @hj it’s assigning the increment the one that it’s undefined (i = i++;)
-
Embed this notice
narcolepsy and alcoholism :flag: (hj@shigusegubu.club)'s status on Wednesday, 25-Oct-2023 02:33:07 JST narcolepsy and alcoholism :flag: @Moon @lanodan the joke is that even if it was c > ++c it would still be false because c is incrementing, not decrementing
equals though is a different story.
at least in JS:
a === ++a
false
a === a++
true -
Embed this notice
narcolepsy and alcoholism :flag: (hj@shigusegubu.club)'s status on Wednesday, 25-Oct-2023 02:45:04 JST narcolepsy and alcoholism :flag: @applejack @lanodan @Moon
a > ++a === undefined
false -
Embed this notice
applejack 🇮🇸:hitlergrin2: (applejack@gameliberty.club)'s status on Wednesday, 25-Oct-2023 02:45:05 JST applejack 🇮🇸:hitlergrin2: @hj @lanodan @Moon It's not false or true, it's completely undefined. The rules for sequencing explicitly state that you can only update a variable once between sequence points
The compiler is allowed to read C into register B, then increment C in place, then read C into register A, and then conclude that A > B
-
Embed this notice
Haelwenn /элвэн/ :triskell: (lanodan@queer.hacktivis.me)'s status on Wednesday, 25-Oct-2023 02:47:38 JST Haelwenn /элвэн/ :triskell: @hj @Moon Meanwhile in reality rather than code: C !== C++
As C++ is long gone from being a pure superset of C, both evolved in their own ways. -
Embed this notice
Haelwenn /элвэн/ :triskell: (lanodan@queer.hacktivis.me)'s status on Wednesday, 25-Oct-2023 03:16:49 JST Haelwenn /элвэн/ :triskell: @ledoian @hj @Moon Ooh… yeah that part might be.
And yeah C is a language where clever-code/code-golfing will just result in broken behavior, I don't think I would do a comparaison and an increment at the same time in actual code. -
Embed this notice
LEdoian (ledoian@pleroma.ledoian.cz)'s status on Wednesday, 25-Oct-2023 03:16:51 JST LEdoian @lanodan @hj @Moon I think the comparison might be actually undefined, since there is no sequence point in that expression, so it is possible that the RHS is evaluated before LHS, thus resulting in true. (Or house fire, given it is UB…)
One of the favourite gotchas of C… I only remember: when pre-/postincrementing, do not do anything clever like reusing the variable. And I had to check the standard to be at least slightly confident in what I write here.