|
Message-ID: <CAAHpriP-VAXady3KhjkYA9vLUskUYqLR7CgkPZ4tAv-tJjoxrA@mail.gmail.com> Date: Wed, 16 Jan 2019 11:06:55 -0800 From: Keith Thompson <keithsthompson@...il.com> To: musl@...ts.openwall.com Cc: Keith Thompson <Keith.S.Thompson@...il.com> Subject: Minor C99 conformance issue: FILE is an incomplete type The musl 1.0.0 manual says that it's intended to conform to C99. Both the C99 and C11 standards require FILE to be an object type. In C99, incomplete types are not object types. In C11, the definition of "object type" was changed, so now incomplete types are object types. (See section C99 and C11 6.2.5, C99 7.19.1, C11 7.21.1.) So, in C99 FILE is not permitted to be an incomplete type, but in C11 it is. (The section describing type FILE did not change. I don't know whether the authors of the standard actually intended to change the requirement.) Using musl-gcc, FILE is an incomplete type, so it conforms to C11 but not to C99. <stdio.h> could be modified so that, for example, it pays attention to the value of __STDC_VERSION__ to decide how to define FILE (whether to make struct _IO_FILE visible). I do not suggest that this minor non-conformance to C99 is a practical problem, or even that it should be fixed, merely that it should be noted. $ cat /etc/lsb-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=18.04 DISTRIB_CODENAME=bionic DISTRIB_DESCRIPTION="Ubuntu 18.04.1 LTS" $ uname -a Linux bomb20 4.15.0-42-generic #45-Ubuntu SMP Thu Nov 15 19:32:57 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux $ dpkg -l musl Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad) ||/ Name Version Architecture Description +++-=========================================-=========================-=========================-======================================================================================= ii musl:amd64 1.1.19-1 amd64 standard C library $ gcc --version gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0 Copyright (C) 2017 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. $ cat FILE_bug.c. #include <stdio.h> int main(void) { printf("sizeof (FILE) = %zu\n", sizeof (FILE)); } $ musl-gcc -std=c99 -c FILE_bug.c FILE_bug.c: In function ‘main’: FILE_bug.c:3:45: error: invalid application of ‘sizeof’ to incomplete type ‘FILE {aka struct _IO_FILE}’ printf("sizeof (FILE) = %zu\n", sizeof (FILE)); ^~~~ $ musl-gcc -std=c11 -c FILE_bug.c FILE_bug.c: In function ‘main’: FILE_bug.c:3:45: error: invalid application of ‘sizeof’ to incomplete type ‘FILE {aka struct _IO_FILE}’ printf("sizeof (FILE) = %zu\n", sizeof (FILE)); ^~~~
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.