[Bug c++/32281] A problem of gcc4.1.0(O3 optimize)

2007-06-11 Thread stillzhang at tencent dot com


--- Comment #3 from stillzhang at tencent dot com  2007-06-11 07:11 ---
I think if "&packet" should be changed, it should change before the function
¡°stmt->set_params¡±. And in fact it is changed after "stmt->set_params¡±, so I
think it's a logical error.

Best wishes,
still


-- 

stillzhang at tencent dot com changed:

   What|Removed |Added

 Status|RESOLVED|UNCONFIRMED
 Resolution|DUPLICATE   |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32281



[Bug c++/32281] A problem of gcc4.1.0(O3 optimize)

2007-06-10 Thread stillzhang at tencent dot com


--- Comment #2 from stillzhang at tencent dot com  2007-06-11 06:07 ---
Thank you.

But if i compiled it without -O3, it work fine.
If I compiled it under gcc3.3 with -O3, it also work fine.

The same program with different optimize has different, so i think it should
not be like this.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32281



[Bug c++/32281] New: A problem of gcc4.1.0(O3 optimize)

2007-06-10 Thread stillzhang at tencent dot com
When I user gcc4.1.0 to compile mysql4.1.22, I find some errors. I¡¯m not sure
whether it¡¯s a gcc bug or not, so I need your help.

   The version of gcc:

   gcc -v

Using built-in specs.

Target: i586-suse-linux

Configured with: ../configure --enable-threads=posix --prefix=/usr
--with-local-prefix=/usr/local --infodir=/usr/share/info
--mandir=/usr/share/man --libdir=/usr/lib --libexecdir=/usr/lib
--enable-languages=c,c++,objc,fortran,java,ada --enable-checking=release
--with-gxx-include-dir=/usr/include/c++/4.1.0 --enable-ssp --disable-libssp
--enable-java-awt=gtk --enable-gtk-cairo --disable-libjava-multilib
--with-slibdir=/lib --with-system-zlib --enable-shared --enable-__cxa_atexit
--enable-libstdcxx-allocator=new --without-system-libunwind --with-cpu=generic
--host=i586-suse-linux

Thread model: posix

gcc version 4.1.0 (SUSE Linux)

Linux verson:

Linux 2.6.16.21-0.8-TENCENT #1 SMP Sat Jan 13 19:17:08 CST 2007 i686 i686 i386
GNU/Linux

Mysql4.1.22 is from http://mysql.he.net/Downloads/MySQL-4.1/mysql-4.1.22.tar.gz
.



The error is in function mysql_stmt_execute(THD *thd, char *packet, uint
packet_length)( mysql-4.1.22/sql/sql_prepare.cc:1786).

The file is complied by these arguments:

g++ -DMYSQL_SERVER -DDEFAULT_MYSQL_HOME="\"/data/home/c4b/still/bin/mysql/\""
-DDATADIR="\"/data/home/c4b/still/bin/mysql//var\""
-DSHAREDIR="\"/data/home/c4b/still/bin/mysql//share/mysql\"" -DHAVE_CONFIG_H
-I. -I. -I.. -I../innobase/include -I../include -I../include -I../regex -I.
-O3 -DDBUG_OFF-fno-implicit-templates -fno-exceptions -fno-rtti -MT
sql_prepare.o -MD -MP -MF ".deps/sql_prepare.Tpo" -g -c -o sql_prepare.o
sql_prepare.cc



In line 1822-1824

1822if (setup_conversion_functions(stmt, (uchar **) &packet, packet_end) ||

   1823 stmt->set_params(stmt, null_array, (uchar *) packet,
packet_end,

   1824  &expanded_query))

And the function ¡°setup_conversion_functions¡± is compiled as inline function.

The lase sentence of in function setup_conversion_functions is *data= read_pos;



The three sentences is compiled to 

0x08197bff <_Z18mysql_stmt_executeP3THDPcj+703>: mov0xc(%ebp),%ecx

0x08197c02 <_Z18mysql_stmt_executeP3THDPcj+706>:mov   
0xffc0(%ebp),%ebx

0x08197c05 <_Z18mysql_stmt_executeP3THDPcj+709>:mov   
0xffb4(%ebp),%eax

0x08197c08 <_Z18mysql_stmt_executeP3THDPcj+712>:mov%ecx,0x8(%esp)

0x08197c0c <_Z18mysql_stmt_executeP3THDPcj+716>:mov   
0xffd0(%ebp),%edx

0x08197c0f <_Z18mysql_stmt_executeP3THDPcj+719>:mov   
0xffb8(%ebp),%ecx

0x08197c12 <_Z18mysql_stmt_executeP3THDPcj+722>:mov%ebx,0xc(%ebp)  
   //*data= read_pos

0x08197c15 <_Z18mysql_stmt_executeP3THDPcj+725>:lea   
0xffdc(%ebp),%ebx

0x08197c18 <_Z18mysql_stmt_executeP3THDPcj+728>:mov%ebx,0x10(%esp)

0x08197c1c <_Z18mysql_stmt_executeP3THDPcj+732>:mov%eax,0xc(%esp)

0x08197c20 <_Z18mysql_stmt_executeP3THDPcj+736>:mov%edx,0x4(%esp)

0x08197c24 <_Z18mysql_stmt_executeP3THDPcj+740>:mov%ecx,(%esp)

0x08197c27 <_Z18mysql_stmt_executeP3THDPcj+743>:call   *0x764(%ecx)



0xc(%ebp) is the address of &packet(in function mysql_stmt_execute) and also
the address of *data(in function setup_conversion_functions).

In 703 and 712, we can see the value of 0xc(%ebp) is push to stack for the
third argument of function stmt->set_params.

The sentence 722 is for *data= read_pos, Move the read_pos to *data(address
0xc(%ebp)).



So the third argument of function stmt->set_params use the old value not the
new value. 





Am I right£¿Wait for your reply, and thank you very much.





Best wishes,

Still


-- 
   Summary: A problem of gcc4.1.0(O3 optimize)
   Product: gcc
   Version: 4.1.0
    Status: UNCONFIRMED
          Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: stillzhang at tencent dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32281