public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/32281]  New: A problem of gcc4.1.0(O3 optimize)
@ 2007-06-11  3:38 stillzhang at tencent dot com
  2007-06-11  3:41 ` [Bug c++/32281] " pinskia at gcc dot gnu dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: stillzhang at tencent dot com @ 2007-06-11  3:38 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 4105 bytes --]

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/32281] A problem of gcc4.1.0(O3 optimize)
  2007-06-11  3:38 [Bug c++/32281] New: A problem of gcc4.1.0(O3 optimize) stillzhang at tencent dot com
@ 2007-06-11  3:41 ` pinskia at gcc dot gnu dot org
  2007-06-11  6:07 ` stillzhang at tencent dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-06-11  3:41 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2007-06-11 03:41 -------
So packet is char*, and you are accessing it as uchar*, so this code is
violating C/C++ aliasing rules.

*** This bug has been marked as a duplicate of 21920 ***


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |DUPLICATE
            Summary|A problem of gcc4.1.0(O3    |A problem of gcc4.1.0(O3
                   |optimize)                   |optimize)


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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/32281] A problem of gcc4.1.0(O3 optimize)
  2007-06-11  3:38 [Bug c++/32281] New: A problem of gcc4.1.0(O3 optimize) stillzhang at tencent dot com
  2007-06-11  3:41 ` [Bug c++/32281] " pinskia at gcc dot gnu dot org
@ 2007-06-11  6:07 ` stillzhang at tencent dot com
  2007-06-11  7:12 ` stillzhang at tencent dot com
  2007-06-11 12:23 ` rguenth at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: stillzhang at tencent dot com @ 2007-06-11  6:07 UTC (permalink / raw)
  To: gcc-bugs



------- 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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/32281] A problem of gcc4.1.0(O3 optimize)
  2007-06-11  3:38 [Bug c++/32281] New: A problem of gcc4.1.0(O3 optimize) stillzhang at tencent dot com
  2007-06-11  3:41 ` [Bug c++/32281] " pinskia at gcc dot gnu dot org
  2007-06-11  6:07 ` stillzhang at tencent dot com
@ 2007-06-11  7:12 ` stillzhang at tencent dot com
  2007-06-11 12:23 ` rguenth at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: stillzhang at tencent dot com @ 2007-06-11  7:12 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 636 bytes --]



------- 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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug c++/32281] A problem of gcc4.1.0(O3 optimize)
  2007-06-11  3:38 [Bug c++/32281] New: A problem of gcc4.1.0(O3 optimize) stillzhang at tencent dot com
                   ` (2 preceding siblings ...)
  2007-06-11  7:12 ` stillzhang at tencent dot com
@ 2007-06-11 12:23 ` rguenth at gcc dot gnu dot org
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-06-11 12:23 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from rguenth at gcc dot gnu dot org  2007-06-11 12:23 -------
It is still violating aliasing rules.  That only -O3 fails is because -O3
enables
-finline-functions, so it should as well fail with lower optimization settings
with -finline-functions.  Also -fno-strict-aliasing will fix it.

*** This bug has been marked as a duplicate of 21920 ***


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |DUPLICATE


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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-06-11 12:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-11  3:38 [Bug c++/32281] New: A problem of gcc4.1.0(O3 optimize) stillzhang at tencent dot com
2007-06-11  3:41 ` [Bug c++/32281] " pinskia at gcc dot gnu dot org
2007-06-11  6:07 ` stillzhang at tencent dot com
2007-06-11  7:12 ` stillzhang at tencent dot com
2007-06-11 12:23 ` rguenth at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).