Skip to content
Snippets Groups Projects
  • Rainer Orth's avatar
    3cec4911
    libssp: Fix gets-chk.c compilation on Solaris · 3cec4911
    Rainer Orth authored
    The recent warning patches broke the libssp build on Solaris:
    
    /vol/gcc/src/hg/master/local/libssp/gets-chk.c: In function '__gets_chk':
    /vol/gcc/src/hg/master/local/libssp/gets-chk.c:67:12: error: implicit
    declaration of function 'gets'; did you mean 'getw'?
    [-Wimplicit-function-declaration]
       67 |     return gets (s);
          |            ^~~~
          |            getw
    /vol/gcc/src/hg/master/local/libssp/gets-chk.c:67:12: error: returning
    'int' from a function with return type 'char *' makes pointer from integer
    without a cast [-Wint-conversion]
       67 |     return gets (s);
          |            ^~~~~~~~
    /vol/gcc/src/hg/master/local/libssp/gets-chk.c:74:12: error: returning
    'int' from a function with return type 'char *' makes pointer from integer
    without a cast [-Wint-conversion]
       74 |     return gets (s);
          |            ^~~~~~~~
    
    The guard around the gets declaration in gets-chk.c is
    
          || (defined __cplusplus && __cplusplus <= 201103L))
    extern char *gets (char *);
    
    where __USE_ISOC11 is glibc-only, while Solaris <iso/stdio_iso.h> declares
    gets like
    
    extern char     *gets(char *) __ATTR_DEPRECATED;
    
    Instead of using a target-specific macro, this patch just uses the
    canonical autoconf test.
    
    Tested on i386-pc-solaris2.11, sparc-sun-solaris2.11,
    x86_64-pc-linux-gnu, x86_64-apple-darwin23.3.0, and amd64-freebsd14.0.
    
    2023-12-07  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
    
    	libssp:
    	* configure.ac (AC_CHECK_DECLS): Check for gets.
    	* configure, config.h.in: Regenerate.
    	* gets-chk.c (gets): Guard declaration with !HAVE_DECL_GETS.
    3cec4911
    History
    libssp: Fix gets-chk.c compilation on Solaris
    Rainer Orth authored
    The recent warning patches broke the libssp build on Solaris:
    
    /vol/gcc/src/hg/master/local/libssp/gets-chk.c: In function '__gets_chk':
    /vol/gcc/src/hg/master/local/libssp/gets-chk.c:67:12: error: implicit
    declaration of function 'gets'; did you mean 'getw'?
    [-Wimplicit-function-declaration]
       67 |     return gets (s);
          |            ^~~~
          |            getw
    /vol/gcc/src/hg/master/local/libssp/gets-chk.c:67:12: error: returning
    'int' from a function with return type 'char *' makes pointer from integer
    without a cast [-Wint-conversion]
       67 |     return gets (s);
          |            ^~~~~~~~
    /vol/gcc/src/hg/master/local/libssp/gets-chk.c:74:12: error: returning
    'int' from a function with return type 'char *' makes pointer from integer
    without a cast [-Wint-conversion]
       74 |     return gets (s);
          |            ^~~~~~~~
    
    The guard around the gets declaration in gets-chk.c is
    
          || (defined __cplusplus && __cplusplus <= 201103L))
    extern char *gets (char *);
    
    where __USE_ISOC11 is glibc-only, while Solaris <iso/stdio_iso.h> declares
    gets like
    
    extern char     *gets(char *) __ATTR_DEPRECATED;
    
    Instead of using a target-specific macro, this patch just uses the
    canonical autoconf test.
    
    Tested on i386-pc-solaris2.11, sparc-sun-solaris2.11,
    x86_64-pc-linux-gnu, x86_64-apple-darwin23.3.0, and amd64-freebsd14.0.
    
    2023-12-07  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
    
    	libssp:
    	* configure.ac (AC_CHECK_DECLS): Check for gets.
    	* configure, config.h.in: Regenerate.
    	* gets-chk.c (gets): Guard declaration with !HAVE_DECL_GETS.