There have been multiple accounts created with the sole purpose of posting advertisement posts or replies containing unsolicited advertising.

Accounts which solely post advertisements, or persistently post them may be terminated.

programmer_humor

This magazine is from a federated server and may be incomplete. Browse more on the original instance.

nybble41 , in I mean it could be right

I’m fairly certain that last one is UB in C. The result of an assignment operator is not an lvalue, and even if it were it’s UB (at least in C99) to modify the stored value of an object more than once between two adjacent sequence points. It might work in C++, though.

Beanie ,

That was my first thought when trying to figure out what it did

fluxion , in haha patents

It’s amazing how much work goes into cleaning up code before you feel comfortable posting it to a mailing list that you would never even bother doing for internal-only stuff.

TootSweet , in I mean it could be right

<span style="color:#323232;">for (int y = MIN_INT; y &lt;= MAX_INT; y++) {
</span><span style="color:#323232;">        if (y == x + 1) {
</span><span style="color:#323232;">                x = y;
</span><span style="color:#323232;">        }
</span><span style="color:#323232;">}
</span>

(Not sure there’s a way to prevent Lemmy from escaping my left angle bracket. I definitely didn’t type ampersand-el-tee. You’ll just have to squint and pretend. I’m using the default lemmy-ui frontend.)

xthexder ,
@xthexder@l.sw0.com avatar

y &lt;= MAX_INT will never be false, since the loop will overflow and wrap around to MIN_INT

(You can escape code with backticks, and regular markdown rules)

TootSweet ,

Oh good call! What I was trying to do is more complex than I was thinking.

Hmmmmm.


<span style="color:#323232;">int f = TRUE;
</span><span style="color:#323232;">for (int y = MIN_INT; f || y - 1 &lt; y; y++) {
</span><span style="color:#323232;">  f = FALSE;
</span><span style="color:#323232;">  if (y == x + 1) {
</span><span style="color:#323232;">    x = y;
</span><span style="color:#323232;">  }
</span><span style="color:#323232;">}
</span>

(I should just test my code to make sure it works, but I haven’t. Heh.)

Also, Lemmy escaped your angle bracket too. Back ticks don’t seem to do the trick.


<span style="color:#323232;">Block: &lt;
</span>

Inline: &lt;

Or were you suggesting back ticks for some other purpose? (I did use back ticks in my first post in this thread.)

xthexder ,
@xthexder@l.sw0.com avatar

The backticks worked in the preview, and showed up correctly to start, but there must be a bug in the lemmy ui, since now it’s double-escaped. No idea /shrug

mormegil ,
@mormegil@programming.dev avatar

It will not “overflow”. Signed integer overflow is undefined behavior. The compiler could remove the whole loop or do anything else imaginable (or not).

TootSweet ,

TIL!

I wonder how many languages out there do define what happens on integer overflow.

BatmanAoD ,

Languages with dynamic typing and implicit large-integer types, such as Python and Ruby, generally just convert to that large-integer type.

I figured Java would probably define the behavior in the JVM, but based on a quick web search it sounds like it probably doesn’t by default, but does provide library methods to add or subtract safely.

Rust guarantees a panic by default, but provides library methods for wrapping, saturating, and unchecked (i.e. unsafely opting back in to undefined behavior).

abbadon420 , in I mean it could be right

The third one is just (x=x+1), because the middle bit is just always false and can be ignored.

Hotzilla ,

What if int overflows? Is it still false?

rhpp ,

Still false, thanks to compiler optimizations. Remember that integer overflow is UB. (unless you’re using unsigned int or a programming language which strictly defines integer overflow, possibly as an error)

P.S.: Assuming this is C/C++

chellomere ,

No, because it’s UB, the compiler is free to do whatever, like making demons fly out of your nose

SpaceNoodle , in I mean it could be right

++x;

damium , (edited )

The underutilized post pre increment operator.

Blamemeta , in I mean it could be right

When the metric is lines of code

mcmoor ,

When the company tries to be cheeky and starts to count characters instead

Johanno ,

Rename c to completelyUnimportantVariableThatISoLongBecauseIGetPaidMore

lugal , in Language

Don’t look up Danish numbers.

Worst mistake of my life

President_Pyrus ,
@President_Pyrus@feddit.dk avatar

9+(5-1/2)*20

Source: Look at which instance I’m on.

BlueBockser , in Language

Shouldn’t it be “90+9” for English, though?

alx OP , in Race Condition
@alx@programming.dev avatar

knock knock

who’s there?

threads.

threthreadsads whthreadso?

mindbleach , in Race Condition

I know a joke about UDP, but you might not get it.

Johanno ,

Can you send it via TCP?

mindbleach ,

Yeah, are you ready?

mrbn , in Race Condition
@mrbn@lemmy.ca avatar

Good one, let me try!

Knock knock

Who’s there?

Race Condition

funkajunk ,
@funkajunk@lemm.ee avatar

Works on my machine!

stanka ,

We are not shipping your machine, @funkajunk!

droans ,

Well, that’s basically just containers.

Xanvial ,

Seems the bug is fixed, let’s ship it

nogrub ,

deploy on friday

Blackmist , in The temptation is always there

Nothing wrong with global variables.

If anyone asks just say it’s the singleton pattern.

404 , in Race Condition

“Did you get the reference? Do you need a pointer?”

dukk ,

For those who don’t understand, he mea Segmentation fault (core dumped)

404 ,

C this guy gets it!

smik , in I'm just at home heating up my no-code offering in the microwave...
@smik@discuss.tchncs.de avatar

So… too many cooks creating overly complicated meals that occasionally are admirably but more often then not are not worth the money. Also really hard to get into and make more efficient.

Bloated complex frontend with so gosh darn many tools, some specifically created for one certain meals but sometimes get used for other meals, more or less effective. Sometimes it’s already at the table, sometimes gets delivered with your meal.

Fancy looking APIs but you somehow have to know how to correctly talk to them and if you phrase something wrong, well good luck.

VS:

Simple, efficient, maybe not as sophisticated but if you get too many customers: just order a second one.

RacoonVegetable , in Race Condition

Knock knock

Amongus

Who’s there?

😳

darcy ,
@darcy@sh.itjust.works avatar

SUS!!!1!!!1!!!

  • All
  • Subscribed
  • Moderated
  • Favorites
  • [email protected]
  • random
  • lifeLocal
  • goranko
  • All magazines