Project

General

Profile

Actions

Bug #13315

closed

Single "%" at the end of `printf` format string appears in the result

Added by nobu (Nobuyoshi Nakada) over 7 years ago. Updated over 7 years ago.

Status:
Closed
Target version:
-
[ruby-core:80153]

Description

Is this intentional?

printf("%") #=> "%"

printf in glibc does print nothing, gcc warns though.

#include <stdio.h>

int main(void)
{
  printf("%");
  return 0;
}
$ gcc fmt.c && ./a.out 
fmt.c: In function ‘main’:
fmt.c:5:10: warning: spurious trailing ‘%’ in format [-Wformat=]
   printf("%");
          ^

printf command of bash errs.

$ printf "%"
-bash: printf: `%': missing format character

Related issues 2 (0 open2 closed)

Related to Ruby master - Bug #20439: Invalid string format with n$ flag is ignored in some caseClosedActions
Related to Ruby master - Bug #20438: String format "%\n" and "%\0" does not raise format errorClosedActions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0