This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/79055] New: gcc should not warn about the assignment-allocation character 'm' of scanf when POSIX is enabled


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79055

            Bug ID: 79055
           Summary: gcc should not warn about the assignment-allocation
                    character 'm' of scanf when POSIX is enabled
           Product: gcc
           Version: 6.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: stefan.tauner at gmx dot at
  Target Milestone: ---

Created attachment 40499
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=40499&action=edit
MWE

The attached file produces...

scanfm.c: In function ‘main’:
scanfm.c:6:11: warning: ISO C does not support the 'm' scanf flag [-Wformat=]
     scanf("%ms %mc %m[a-z]", &s, &c, &p);
           ^
scanfm.c:6:11: warning: ISO C does not support the 'm' scanf flag [-Wformat=]
scanfm.c:6:11: warning: ISO C does not support the 'm' scanf flag [-Wformat=]

etc. when compiled with gcc when -pedantic (and in some versions -Wall) is used
even if _POSIX_C_SOURCE is set to 200809L, e.g.,

gcc -Wall -D_POSIX_C_SOURCE=200809L -pedantic -std=c99 scanfm.c -o scanfm

The 'm' allocation character is specified in POSIX 2008[1] and thus I think
gcc should not warn if _POSIX_C_SOURCE or _XOPEN_SOURCE are set appropriately
since there is not other way to inform gcc about the usage of POSIX AFAICT
(cf. bug #45289 which was about the void * to function pointer conversion
needed when using dlsym()). The message is of course pedantically (pun
intended) correct as expected from a decent compiler but not helpful to users.

The behavior is roughly the same up to at least 6.2.1 (Debian's version, whose
maintainer asked me to file upstream, downstream bug is at
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=850892).

1: http://pubs.opengroup.org/onlinepubs/9699919799/functions/fscanf.html

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]