> [email protected] (Joerg Schilling) writes:
>
>> The problem with GCC-4.4 is that it cannot be called ANSI C compliant.
>> I did e.g. not jet find a way to prevent a warning for this line:
>>
>>      (void)write(1, "Test" 4);
>>
>> which is 100% correct and even marks the return value as out of interest
>> but this fact is ignored by gcc.
>
> I don't get any warning whatsoever:
>
> $ cat void-write.c
> #include <unistd.h>
>
> int
> main (void)
> {
>   write (1, "Test", 4);
>   (void) write (1, "Test", 4);
>   return 0;
> }
> $ gcc-4.4 -c -O2 -Wall void-write.c
> $
>
> Same with -ansi -pedantic.  What options did you use to get a warning in
> this case?
>
>       Rainer
>

I see Studio 11 is not happy with that at all :

$ cat -n fault.c
     1  /* Feature test switches */
     2  #define _POSIX_SOURCE 1
     3
     4  /* System Headers */
     5  #include <stdio.h>
     6  #include <unistd.h>
     7
     8  /*
     9   * Main function
    10   */
    11  int
    12  main (int argc, char *argv[]) {
    13      printf ( "Hello World!\n" );
    14      /* From [email protected] (Joerg Schilling) */
    15      (void)write(1, "Test" 4);
    16      return (0);
    17  } /* End of main */
$
$ which cc
/opt/studio/SOS11/SUNWspro/bin/cc
$ cc -V
cc: Sun C 5.8 Patch 121016-08 2009/04/20
usage: cc [ options] files.  Use 'cc -flags' for details
$ cc -xarch=386 -Xc -Kpic -\# -H -c -o fault.o fault.c
### Note: NLSPATH =
/opt/SUNWspro/prod/bin/../lib/locale/%L/LC_MESSAGES/%N.cat:/opt/SUNWspro/prod/bin/../../lib/locale/%L/LC_MESSAGES/%N.cat
###     command line files and options (expanded):
### -c -H -Kpic -Xc -xarch=386 fault.c -o fault.o
/opt/SUNWspro/prod/bin/acomp -xldscope=global -i fault.c -y-fbe
-y/opt/SUNWspro/prod/bin/fbe -y-pic -y-xarch=386 -y-o -yfault.o -y-verbose
-y-xthreadvar=dynamic -y-comdat -xdbggen=no%stabs+dwarf2+usedonly -H -2k
-fparam_ir -Qy -D__SunOS_5_8 -D__SUNPRO_C=0x580 -D__SVR4 -D__unix -D__sun
-D__i386 -D__BUILTIN_VA_ARG_INCR -D__C99FEATURES__ -Xc
-D__PRAGMA_REDEFINE_EXTNAME -xc99=%all,no%lib -D__FLT_EVAL_METHOD__=-1
-I/opt/SUNWspro/prod/include/cc "-g/opt/SUNWspro/prod/bin/cc -xarch=386
-Xc -Kpic -H -c -o fault.o " -fsimple=0 -destination_ir=yabe
/usr/include/stdio.h
        /usr/include/iso/stdio_iso.h
                /usr/include/sys/feature_tests.h
                        /usr/include/sys/isa_defs.h
                /usr/include/sys/va_list.h
                /usr/include/stdio_tag.h
                /usr/include/stdio_impl.h
/usr/include/unistd.h
        /usr/include/sys/types.h
                /usr/include/sys/machtypes.h
                        /usr/include/ia32/sys/machtypes.h
                /usr/include/sys/int_types.h
        /usr/include/sys/unistd.h
"fault.c", line 15: syntax error before or at: 4
cc: acomp failed for fault.c


What does gcc say ?

$ gas --version
GNU assembler (GNU Binutils) 2.19.1
Copyright 2007 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or later.
This program has absolutely no warranty.
This assembler was configured for a target of `i386-pc-solaris2.8'.
$ gcc --version
gcc (GCC) 4.4.3
Copyright (C) 2010 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.

$ gcc -std=iso9899:1999 -pedantic -march=i386 -malign-double -mno-mmx \
> -mno-sse -m32 -v -c -o fault.o fault.c
Using built-in specs.
Target: i386-pc-solaris2.8
Configured with: ../gcc-4.4.3/configure --build=i386-pc-solaris2.8
--with-gnu-as --with-as=/opt/csw/bin/gas --without-gnu-ld
--with-ld=/usr/ccs/bin/ld --with-cpu-32=i386 --with-arch-32=i386
--enable-stage1-languages=c --enable-nls --with-libiconv-prefix=/opt/csw
--enable-threads=posix --prefix=/opt/csw/src/gcc-4.4.3-proto
--with-local-prefix=/opt/csw/src/gcc-4.4.3-proto --enable-shared
--enable-multilib --with-included-gettext --with-system-zlib
--with-gmp=/opt/csw --with-mpfr=/opt/csw --with-mpc=/opt/csw
--enable-languages=c,c++,objc,fortran,ada,java --enable-bootstrap
Thread model: posix
gcc version 4.4.3 (GCC)
COLLECT_GCC_OPTIONS='-std=iso9899:1999' '-pedantic' '-march=i386'
'-malign-double' '-mno-mmx' '-mno-sse' '-m32' '-v' '-c' '-o' 'fault.o'
 /export/nfs2/gcc-4.4.3-proto/bin/../libexec/gcc/i386-pc-solaris2.8/4.4.3/cc1
-quiet -v -iprefix
/export/nfs2/gcc-4.4.3-proto/bin/../lib/gcc/i386-pc-solaris2.8/4.4.3/
fault.c -quiet -dumpbase fault.c -march=i386 -malign-double -mno-mmx
-mno-sse -m32 -auxbase-strip fault.o -pedantic -std=iso9899:1999 -version
-o /var/tmp//ccfavQf9.s
ignoring nonexistent directory
"/export/nfs2/gcc-4.4.3-proto/bin/../lib/gcc/i386-pc-solaris2.8/4.4.3/../../../../i386-pc-solaris2.8/include"
ignoring nonexistent directory "/opt/csw/src/gcc-4.4.3-proto/include"
ignoring duplicate directory
"/export/nfs2/gcc-4.4.3-proto/bin/../lib/gcc/../../lib/gcc/i386-pc-solaris2.8/4.4.3/include"
ignoring duplicate directory
"/export/nfs2/gcc-4.4.3-proto/bin/../lib/gcc/../../lib/gcc/i386-pc-solaris2.8/4.4.3/include-fixed"
ignoring nonexistent directory
"/export/nfs2/gcc-4.4.3-proto/bin/../lib/gcc/../../lib/gcc/i386-pc-solaris2.8/4.4.3/../../../../i386-pc-solaris2.8/include"
#include "..." search starts here:
#include <...> search starts here:
 /export/nfs2/gcc-4.4.3-proto/bin/../lib/gcc/i386-pc-solaris2.8/4.4.3/include
 
/export/nfs2/gcc-4.4.3-proto/bin/../lib/gcc/i386-pc-solaris2.8/4.4.3/include-fixed
 /usr/include
End of search list.
GNU C (GCC) version 4.4.3 (i386-pc-solaris2.8)
        compiled by GNU C version 4.4.3, GMP version 5.0.1, MPFR version
2.4.2.
GGC heuristics: --param ggc-min-expand=82 --param ggc-min-heapsize=98255
Compiler executable checksum: b2dca01ef80df0bea2c8156c4218df84
fault.c: In function 'main':
fault.c:15: error: expected ')' before numeric constant
fault.c:15: error: too few arguments to function 'write'
$

I'm not seeing a problem here really. Both Studio and GCC seem to agree.

-- 
Dennis Clarke
[email protected]  <- Email related to the open source Solaris
[email protected]   <- Email related to open source for Solaris


_______________________________________________
opensolaris-code mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code

Reply via email to