tigranh / lr_printer

The repository for "LR printer" algorithm implementation.
GNU General Public License v3.0
4 stars 0 forks source link

Your results are not reproducible #1

Open tau-dev opened 2 weeks ago

tau-dev commented 2 weeks ago

The code contains undefined behavior, such as integer overflows: https://github.com/tigranh/lr_printer/blob/a85bfbc218d410d0cbfb4be14fb3fd10cfd27bc7/lr_printer.hpp#L180 https://github.com/tigranh/lr_printer/blob/a85bfbc218d410d0cbfb4be14fb3fd10cfd27bc7/lr_printer_2_digits.hpp#L231

as well as pointer-out-of bounds on https://github.com/tigranh/lr_printer/blob/a85bfbc218d410d0cbfb4be14fb3fd10cfd27bc7/lr_printer_2_digits.hpp#L111 (even having a pointer out-of-bound of an array is UB, you do not need to dereference it).

Because of this, the code crashes at any degree of optimization in Clang and GCC. Performance measurements of non-optimized builds are near meaningless.

tigranh commented 1 week ago

Can you please specify the exact compiler, which causes such behavior (I mean version, optimization flags, etc...)? What numbers are you printing? Are they of primitive data types, or something else?

tau-dev commented 1 week ago

I tried compiling main.cpp with g++ -O1 on Linux and clang++ -O1 on Linux and Windows. You probably only tested MSVC, which does not exploit UB nearly as much.

tigranh commented 1 week ago

Yes, I tried that only on MSVC. I will try also gcc soon. Are there some specific numbers, printing of which fails... or your issue applies to the general case?

tau-dev commented 1 week ago

Just trying to run main.cpp without modifications