[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
fcntl.h allows inclusion of sys/stat.h in an illegal way
From: |
Johannes Zarl |
Subject: |
fcntl.h allows inclusion of sys/stat.h in an illegal way |
Date: |
Thu, 11 Sep 2014 13:28:11 +0200 |
User-agent: |
KMail/1.13.7 (Linux/3.10-0.bpo.3-amd64; KDE/4.8.4; x86_64; ; ) |
Hi,
fcntl.h as supplied on many glibc systems includes sys/stat.h in an extern "C"
linkage block. Together with the use of namespaces in gnulib sys/stat.h this
results in illegal (as in against the standard) C++ code.
Older gcc versions seem to have diagnosed this correctly, as there is a
workaround for gcc < 4.3 already in place. Newer gcc versions allow this code,
but intel icc does not. The bug is triggered when icc is used to compile
Octave[1]. The bug can also be triggered using the gnulib-tool as follows:
# 1. set up the environment to use intel compilers
# 2. run the test suite:
# ./gnulib-tool --test --with-c++-tests fcntl sys_stat
###############
...snip...
/apps/intel/compiler/composer_xe_2013_sp1.2.144/bin/intel64/icpc -
DHAVE_CONFIG_H -I. -I../../gltests -DGNULIB_STRICT_CHECKING=1 -I. -
I../../gltests -I.. -I../../gltests/.. -I../gllib -I../../gltests/../gllib
-MT test-fcntl-h-c++.o -MD -MP -MF .deps/test-fcntl-h-c++.Tpo -c -o test-
fcntl-h-c++.o ../../gltests/test-fcntl-h-c++.cc
In file included from /usr/include/fcntl.h(38),
from ../gllib/fcntl.h(61),
from ../../gltests/test-fcntl-h-c++.cc(22):
../gllib/sys/stat.h(657): error: declaration is incompatible with previous
"fstat" (declared at line 214 of "/usr/include/sys/stat.h")
_GL_CXXALIAS_SYS (fstat, int, (int fd, struct stat *buf));
^
In file included from /usr/include/fcntl.h(38),
from ../gllib/fcntl.h(61),
from ../../gltests/test-fcntl-h-c++.cc(22):
../gllib/sys/stat.h(786): error: declaration is incompatible with previous
"lstat" (declared at line 263 of "/usr/include/sys/stat.h")
_GL_CXXALIAS_SYS (lstat, int, (const char *name, struct stat *buf));
^
compilation aborted for ../../gltests/test-fcntl-h-c++.cc (code 2)
###################
The attached patch extends the previous workaround for gcc to apply to icc as
well.
[1] https://savannah.gnu.org/bugs/index.php?43171
Cheers,
Johannes
prevent-illegal-c++-code.patch
Description: Text Data
- fcntl.h allows inclusion of sys/stat.h in an illegal way,
Johannes Zarl <=