Wordle_opt not working (but wordle_debug does)

Hey there :smiley:

So I just discovered that when I run my code with wordle_opt, it gives me wrong feedback (the last three letters are always marked as correct), despite wordle_debug working perfectly fine and passing all public and daily tests. The GUI shows a similar behavior so I’m guessing that this also uses the opt version. Do I have to go find out where this bug comes from or does it not impair the correctness of my program?

Without having looked at it further:
A program behaving differently when optimized than it does without optimizations is ALWAYS a strong indication of undefined behaviour!

Most commonly, that means out-of-bounds memory accesses (or dereferencing invalid pointers in other ways) or uninitialized variables or arrays.
Since you did not get any ASAN errors, it is unlikely that you access unallocated memory (though not impossible!).

Therefore, you should go through your code again to make sure you avoid such problems.

1 Like

Just to make sure, are you using Mac OS or the VM? I think the address sanitizer is not working (fully) on mac OS.

The GUI indeed uses the optimized version:
It first compiles the wordle source files into a library to be used by other programs. This compilation uses the optimization flags -O3 which exploit undefined behavior.
Afterward, the GUI compiles itself with -O0 and links dynamically against the wordle library.

1 Like

After a while I found out what the problem was, and yes it was undefined behavior (I believe at least).

I would’ve liked to mark the second post of Johannes as the solution but unfortunately it disappeared!? I also can’t edit the wrong title of the topic anymore, which I had before but it switched back to the wrong one. Something strange is going on with the forum.

Anyway, thanks everyone for the additional information!