compiler icon indicating copy to clipboard operation
compiler copied to clipboard

Functions `printf()` and `strformat()` fail when printing "%%"

Open Daniel-Cortez opened this issue 5 years ago • 2 comments

Issue description:

(The bug described in this issue belongs to the interpreter from this repository (pawnruns), not SA-MP; also, if I understand it correctly, open.mp is also going to use the implementations of format() and printf() from this repo, so I believe this bug report belongs here.)

Printing the percent sign through format specifier %% causes a runtime error.

Minimal complete verifiable example (MCVE):

#include <console>
main()
{
    printf("100%%\n");
}

Output:

100%
Run time error 10: "Native function failed"

Printing % through the %c specifier doesn't cause any errors though:

printf("100%c\n", '%');
100%

Discovered this bug while doing one of the tests for #640.

Workspace Information:

  • Compiler version:
  • Command line arguments provided (or sampctl version):
  • Operating System:

Daniel-Cortez avatar Mar 14 '21 15:03 Daniel-Cortez

That's interesting... We've got a modified version of format/printf in open.mp, but since it didn't touch %% I'll check there. Thanks.

Y-Less avatar May 02 '21 19:05 Y-Less

This issue has been automatically marked as stale because it has not had recent activity.

stale[bot] avatar Jan 09 '22 03:01 stale[bot]