Opened 14 years ago

Closed 14 years ago

#5168 closed Bug report (worksforme)

gcc compiler switches -O2 and -O3 generates bad code. use -O

Reported by: Jim Michaels Owned by:
Priority: normal Component: FileZilla Client
Keywords: Cc:
Component version: Operating system type: Windows
Operating system version: XP Pro Sp3

Description

I have written a SHA512 implementation for my own use, and I could not get get the right test results with integer calculations using gcc -O2 or -O3. So I am saying that gcc -O2 and gcc -O3 both generate corrupt, improper code. gcc -O generates good code.

SHA512 involves a lot of shifts, multiplies, adds. I understand packets (if you are doing that) require calculations as well, for calculating length, size, checksums, etc. so there may be some similarities in the calculations.

I suggest you stay away from using -O2 or -O3 and stick with -O for compiler optimization.

You may find some bugs disappear once you switch to -O.

Suggest you do the same with FileZilla Server.

I also use mingw. I used to use mingw, but now I use mingw-w64, since it has TR1 and it can compile 64-bit code.

There is also a known compiler bug I discovered (gcc folk won't fix it - talk to them?) that -fpack-struct does not work with iostream, locale, fstream C++ libraries. It will generate huge numbers of errors. They said something like it is not supposed to work together or something like that. (bolderdash)

These are not a problem with microsoft or borland commercial compilers.

I am basing this bug on the information I obtained in the Help|About dialog where it says "Compiler Flags":

FileZilla Client


Version: 3.3.1

Build information:

Compiled for: i586-pc-mingw32msvc
Compiled on: x86_64-unknown-linux-gnu
Build date: 2010-01-03
Compiled with: i586-mingw32msvc-gcc (GCC) 4.2.1-sjlj (mingw32-2)
Compiler flags: -g -O2 -Wall -g -fexceptions

Linked against:

wxWidgets: 2.8.10
GnuTLS: 2.8.3

Change History (2)

comment:1 by Jim Michaels, 14 years ago

Summary: gcc compiler flag -O2 and -O3 generates bad code. use -Ogcc compiler switches -O2 and -O3 generates bad code. use -O

comment:2 by Jim Michaels, 14 years ago

Resolution: worksforme
Status: newclosed

hmm. now that I have switched over to mingw-w64 automated build, I don't see the problems (though the compiler crashes). the code is good, even with -O2 and -O3.

please disregard this bug. this probably only applies to mingw, which is where I had the problem, not mingw-w64 I think. I was wrong about mingw-w64, at least for mingw-w32-1.0-bin_i686-mingw_20100129 and mingw-w64-1.0-bin_i686-mingw_20100129. your compiler may vary?

Note: See TracTickets for help on using tickets.