From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26143 invoked by alias); 11 Jun 2007 03:38:44 -0000 Received: (qmail 26102 invoked by uid 48); 11 Jun 2007 03:38:35 -0000 Date: Mon, 11 Jun 2007 03:38:00 -0000 Subject: [Bug c++/32281] New: A problem of gcc4.1.0(O3 optimize) X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "stillzhang at tencent dot com" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2007-06/txt/msg00723.txt.bz2 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 1822 if (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>: mov 0xc(%ebp),%ecx 0x08197c02 <_Z18mysql_stmt_executeP3THDPcj+706>: mov 0xffffffc0(%ebp),%ebx 0x08197c05 <_Z18mysql_stmt_executeP3THDPcj+709>: mov 0xffffffb4(%ebp),%eax 0x08197c08 <_Z18mysql_stmt_executeP3THDPcj+712>: mov %ecx,0x8(%esp) 0x08197c0c <_Z18mysql_stmt_executeP3THDPcj+716>: mov 0xffffffd0(%ebp),%edx 0x08197c0f <_Z18mysql_stmt_executeP3THDPcj+719>: mov 0xffffffb8(%ebp),%ecx 0x08197c12 <_Z18mysql_stmt_executeP3THDPcj+722>: mov %ebx,0xc(%ebp) //*data= read_pos 0x08197c15 <_Z18mysql_stmt_executeP3THDPcj+725>: lea 0xffffffdc(%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