bug-gnulib
[Top][All Lists]
Advanced

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

Re: fcntl.h allows inclusion of sys/stat.h in an illegal way


From: Pádraig Brady
Subject: Re: fcntl.h allows inclusion of sys/stat.h in an illegal way
Date: Thu, 11 Sep 2014 14:48:03 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2

On 09/11/2014 12:28 PM, Johannes Zarl wrote:
> 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

__ICC is the define used until now in gnulib
so we better use that for consistency.

I do see references that __ICC is deprecated in favor of __INTEL_COMPILER,
though we can update those together if needed.

Pushed your fix at: 
http://git.sv.gnu.org/gitweb/?p=gnulib.git;a=commitdiff;h=b8e2c7f

thanks!
Pádraig.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]