Res: Site
Ol�, tudo bem ? Voc� ainda tem interesse na cria��o do seu site e loja virtual ? Att. http://www.e-assis.com.br/?c=g...@gnu.org Tel: (11) 2378-7244
Failed
-> http://www.gnu.org/software/gcc/gcc.html Failed Validation of W3C ! This page is not Valid XHTML 1.0 Transitional ! W3C rules specify that XHTML tags have to be written in lowercase. You have just to replace every "DIV" by "div" and validation will succeed. All the best. :-) _ Gagnez des pc Windows Vista avec Live.com http://www.image-addict.fr/
AMD 64 Problem with assembling
Hello, I have a question concerning successfully assembling and linking the following assembly program on a linux AMD 64 machine: #cpuid2.s View the CPUID Vendor ID string using C library calls .section .datatext output: .asciz "The processor Vendor ID is '%s'\n" .section .bss .lcomm buffer, 12 .section .text .globl main main: movl $0, %eax cpuid movl $buffer, %edi movl %ebx, (%edi) movl %edx, 4(%edi) movl %ecx, 8(%edi) push $buffer push $output call printf addl $8, %esp push $0 call exit This part of a book on assembly programming I am reading. Compile and Link: gcc -o cpuid2 cpuid2.s When running cpuid2 it crashes with a segmentation fault. Which switches do I have to add to call gcc? Thanks a lot! Greetings, Florian
Re: GCC 4.3 Platform List
On Thu, Sep 21, 2006 at 08:43:53PM +0100, Richard Sandiford wrote: > I take David's point about mips{,el}-linux-gnu being another alternative. > I suppose mipsisa64-elf has the advantage of being a simulator target > than anyone can test. I'm not familiar with the kind of testing you guys usualy do on simulators - however since this is the second time it's mentionned I should say that mipsel binaries run just fine in the gxemul simulator. I've recently done a whole debian etch installation that way - see http://zoy.org/~walken/gxemul-etch/HOWTO.html for the instructions. Hope it helps. If you can point me to a page describing what you mean about simulator testing I'd be interested too :) Cheers, -- Michel "Walken" Lespinasse "Bill Gates is a monocle and a Persian cat away from being the villain in a James Bond movie." -- Dennis Miller
A bug?
Hi, The following program segfaults when compiled with gcc but runs fine when compiled with g++ or icc (the intel C compiler) #include struct Hello { char world[20]; }; struct Hello s(){ struct Hello r; r.world[0]='H'; r.world[1]='\0'; return r; } int main(){ printf("%s\n",s().world); } Assigning s() to a variable and then using the variable avoids the segfault. gcc --version returns (GCC) 4.2.4 (Ubuntu 4.2.4-1ubuntu3). Regards, Michel
Re: A bug?
That's strange. When I try to compile this with gcc 4.3.2 on Ubuntu 8.10 (Intel core2 duo) I get stest.c: In function ‘main’: stest.c:13: warning: format ‘%s’ expects type ‘char *’, but argument 2 has type ‘char[20]’ The resulting binary does not segfault but prints garbage (probably uninitialized data). g++ still works fine and does not give any warning, even when compiling with -Wall. Michel Dennis Clarke wrote: Hi, The following program segfaults when compiled with gcc but runs fine when compiled with g++ or icc (the intel C compiler) #include struct Hello { char world[20]; }; struct Hello s(){ struct Hello r; r.world[0]='H'; r.world[1]='\0'; return r; } int main(){ printf("%s\n",s().world); } Assigning s() to a variable and then using the variable avoids the segfault. compiles and works fine with GCC 4.3.2 on Solaris 8/9/10 sun4m/sun4u/i386 $ /opt/csw/gcc4/bin/gcc -v -o foo.o -c foo.c Using built-in specs. Target: sparc-sun-solaris2.8 Configured with: ../gcc-4.3.2/configure --prefix=/opt/csw/gcc4 --with-local-prefix=/opt/csw --with-as=/usr/ccs/bin/as --without-gnu-ld --with-ld=/usr/ccs/bin/ld --with-cpu=v7 --enable-threads=posix --enable-nls --enable-shared --enable-languages=c,c++,fortran,objc --with-gmp=/opt/csw --with-mpfr=/opt/csw --enable-multilib --with-included-gettext --with-libiconv-prefix=/opt/csw --with-x --enable-java-awt=xlib --with-system-zlib --enable-bootstrap Thread model: posix gcc version 4.3.2 (GCC) COLLECT_GCC_OPTIONS='-v' '-o' 'foo.o' '-c' '-mcpu=v7' /opt/csw/gcc4/libexec/gcc/sparc-sun-solaris2.8/4.3.2/cc1 -quiet -v foo.c -quiet -dumpbase foo.c -mcpu=v7 -auxbase-strip foo.o -version -o /var/tmp//ccAHrz2q.s ignoring nonexistent directory "/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.3.2/../../../../sparc-sun-solaris2.8/include" #include "..." search starts here: #include <...> search starts here: /opt/csw/include /opt/csw/gcc4/include /opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.3.2/include /opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.3.2/include-fixed /usr/include End of search list. GNU C (GCC) version 4.3.2 (sparc-sun-solaris2.8) compiled by GNU C version 4.3.2, GMP version 4.2.2, MPFR version 2.3.1. warning: GMP header version 4.2.2 differs from library version 4.2.4. GGC heuristics: --param ggc-min-expand=47 --param ggc-min-heapsize=32768 Compiler executable checksum: 1ac791ab3c2b7cc8775dc74d45095fef COLLECT_GCC_OPTIONS='-v' '-o' 'foo.o' '-c' '-mcpu=v7' /usr/ccs/bin/as -V -Qy -s -xarch=v8 -o foo.o /var/tmp//ccAHrz2q.s /usr/ccs/bin/as: Sun WorkShop 6 2003/12/18 Compiler Common 6.0 Patch 114802-02 COMPILER_PATH=/opt/csw/gcc4/libexec/gcc/sparc-sun-solaris2.8/4.3.2/:/opt/csw/gcc4/libexec/gcc/sparc-sun-solaris2.8/4.3.2/:/opt/csw/gcc4/libexec/gcc/sparc-sun-solaris2.8/:/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.3.2/:/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/:/usr/ccs/bin/ LIBRARY_PATH=/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.3.2/:/usr/ccs/lib/:/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.3.2/../../../:/lib/:/usr/lib/ COLLECT_GCC_OPTIONS='-v' '-o' 'foo.o' '-c' '-mcpu=v7' $ /opt/csw/gcc4/bin/gcc -v -o foo.s -S -c foo.c Using built-in specs. Target: sparc-sun-solaris2.8 Configured with: ../gcc-4.3.2/configure --prefix=/opt/csw/gcc4 --with-local-prefix=/opt/csw --with-as=/usr/ccs/bin/as --without-gnu-ld --with-ld=/usr/ccs/bin/ld --with-cpu=v7 --enable-threads=posix --enable-nls --enable-shared --enable-languages=c,c++,fortran,objc --with-gmp=/opt/csw --with-mpfr=/opt/csw --enable-multilib --with-included-gettext --with-libiconv-prefix=/opt/csw --with-x --enable-java-awt=xlib --with-system-zlib --enable-bootstrap Thread model: posix gcc version 4.3.2 (GCC) COLLECT_GCC_OPTIONS='-v' '-o' 'foo.s' '-S' '-c' '-mcpu=v7' /opt/csw/gcc4/libexec/gcc/sparc-sun-solaris2.8/4.3.2/cc1 -quiet -v foo.c -quiet -dumpbase foo.c -mcpu=v7 -auxbase-strip foo.s -version -o foo.s ignoring nonexistent directory "/opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.3.2/../../../../sparc-sun-solaris2.8/include" #include "..." search starts here: #include <...> search starts here: /opt/csw/include /opt/csw/gcc4/include /opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.3.2/include /opt/csw/gcc4/lib/gcc/sparc-sun-solaris2.8/4.3.2/include-fixed /usr/include End of search list. GNU C (GCC) version 4.3.2 (sparc-sun-solaris2.8) compiled by GNU C version 4.3.2, GMP version 4.2.2, MPFR version 2.3.1. warning: GMP header version 4.2.2 differs from library version 4.2.4. GGC heuristics: --param ggc-min-expand=47 --param ggc-min-heapsize=32768 Compiler executable checksum: 1ac791ab3c2b7cc8775dc74d45095fef COMPILER_PATH=/opt/csw/gc
Re: no conversion from char[] to char* on function calls under circumstances [was: A bug?]
Ok thanks for the clear explanation! Not being able to threat char[] as a string is rather shocking to me though. Regards, Michel
Re: A bug
The C standard says no such thing; only integer promotions are performed. (See 6.5.2.2 of the C99 final draft.) Ok one more question. Why does this not give a warning then (and runs fine)? #include struct Hello { char world[20]; }; struct Hello s(){ struct Hello r; r.world[0]='H'; r.world[1]='\0'; return r; } int main(){ struct Hello a; a=s(); printf("%s\n",a.world); return 0; } In this case an implicit conversion of char[] to (char *) is happening as well as far as I can see. Regards, Michel
Re: no conversion from char[] to char* on function calls under circumstances [was: A bug?]
Andrew Haley wrote: Andrew Thomas Pinski wrote: C++98 is not C99 :) there is no rvalue to lvalue conversion for rvalue arrays in C++98. Also this code is still undefined C99 but will most likely become valid C1x. Ah, it's an rvalue array. Good point. Ok now I understand. I assume this behaviour is not triggered often as in C it is not so common to have an array which is an rvalue. Michel Sent from my iPhone Advertising on gcc list. Dear me... ;-) Andrew.
strcpy and strcat seem to lead to a stack overflow
Dear developers: I find it counterintuitive that if I repeatedly reset a variable by using strcpy with an empty string "" to that variable and then us strcat to add characters to that variable that that seems to lead to a stack overflow. I would expect strcpy to first free the variable, then malloc, then copy the string value into the variable. I think that would be a better interpretation, because it can keep running for quite some time before it overflows and doesn’t really call it. Instead, I got "Illegal instruction: 4". I ended up reimplementing the reset function, implementing it with free and malloc myself, but the way strings have been implemented in C is highly counter-intuitive. In general pointers tend to be bug-prone, but here you would expect this not to happen. I hope you can fix this. Personally, I’m looking into switching to Ada. All the best, Emile M. Hobo - Au fin! Et encore en plus. -