[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#850892: gcc should not warn about the assignment-allocation character 'm' when POSIX is enabled



package: gcc
version: 4:6.2.1-1

Hi,

there was a previous bug report about the issue in question (#584511)
but it was closed and archived because it was targeting gcc-4.4 which
was removed from Debian (I tried to reopen it to no avail). However,
the problem persists in (probably) all versions including the gcc in
Ubuntu 16.04 and up to the one in Debian testing at the moment of this
writing (4:6.2.1-1). The allocation modifier in question is specified
here:
http://pubs.opengroup.org/onlinepubs/9699919799/functions/fscanf.html

Attached you can find an example program that shows the problem and
explains it in more detail.

-- 
Dipl.-Ing. Stefan Tauner
Research and Development
Embedded Systems Department

University of Applied Sciences Technikum Wien
Hoechstaedtplatz 6, 1200 Vienna, Austria
T: +43 1 333 40 77-316
E: stefan.tauner@technikum-wien.at
I: embsys.technikum-wien.at
I: www.technikum-wien.at
#include <stdio.h>
#include <stdlib.h>

int main() {
    char *s, *p, *c;
    scanf("%ms %mc %m[a-z]", &s, &c, &p);
    printf("s is %s, c is %c, p is %s\n", s, *c, p);
    free(s);
    free(c);
    free(p);
}

/*

This 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 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.

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

*/

Reply to: