This was fixed correctly in gcc-4.8 (in utopic), but not in gcc-4.9:

  $ cat format-extra-args.c
  #include <stdio.h>

  /* printf extra arguments example */
  int main(void)
  {
        printf("%s\n", "argument 1", "argument 2");

        return 0;
  }
  $ gcc-4.9 --version
  gcc-4.9 (Ubuntu 4.9.0-4ubuntu4) 4.9.0
  Copyright (C) 2014 Free Software Foundation, Inc.
  This is free software; see the source for copying conditions.  There is NO
  warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
  $ gcc-4.9 -O2 -o format-off format-extra-args.c -Wno-format
  format-extra-args.c: In function ‘main’:
  format-extra-args.c:12:2: warning: too many arguments for format 
[-Wformat-extra-args]
    printf("%s\n", "argument 1", "argument 2");
    ^

With the fixed version in gcc-4.8, the output should look like so

  $ gcc-4.8 --version
  gcc-4.8 (Ubuntu 4.8.2-23ubuntu1) 4.8.2
  Copyright (C) 2013 Free Software Foundation, Inc.
  This is free software; see the source for copying conditions.  There is NO
  warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
  $ gcc-4.8 -O2 -o format-off format-extra-args.c -Wno-format
  $

gcc-4.9 still needs the attached patch applied.

** Patch added: "gcc-default-fix-format.diff"
   
https://bugs.launchpad.net/ubuntu/+source/gcc-4.9/+bug/1317305/+attachment/4117744/+files/gcc-default-fix-format.diff

** Changed in: gcc-4.9 (Ubuntu)
       Status: Fix Released => Confirmed

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1317305

Title:
  -Wno-format is not honored

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gcc-4.8/+bug/1317305/+subscriptions

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to