This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Optimization o2 vs o3 issue


Hi,

This is Manish from India and I am facing an issue with g++ 4.1.1. optimization flag  '-o3'

"We are running A SW which is combination of new developed code + Standard Inhouse Developed Libraries. I am testing it on two machines , one we have in India and one in US. At both places Developed Code is exactly same , Inhouse Libs are also supposed to be same but there might be very slight variation  . Same code base is passing in India for both Debug and Release version . In US , debug version passes but release version fails. Fail means, it compiles and builds but when we run test ,there is 
data lose somewhere hence test fails.

 We zeroed down issue to these two lines in a CPP
    
#Line1#    dout.data[15 - count] = (uint8_t)(((long long unsigned int)(*(soc_cpr_dbusdataout_->sig_value_upper)) & (mask << ((8+count)*8)))>>((8+count)*8)); 
#Line2#    cout << "Dout data " << (uint64_t)((dout.data)[15-count]) << endl;

In US, if we comment 2nd line in RELEASE build (as we should), it FAILS with -o3 switch.  If we put -o2  switch ,it PASSES. We also tried with -finline-functions switch with o2/o3 but it didn't change scene. Unfortunately we use -o3 in our releases. So we are left no option but to have this 'cout' in the code so that it can work.

Seems like its NOT totally unknown issue with GCC4.x family ( we are using gcc4.1.1), some other people Have shared similar griefs.

Also, just to play around we tried replacing second line with some other lines like
     cout << "--------------------------------------------------------" << endl;
     int temp = (uint64_t)((dout.data)[15-count]) ; (void)temp ; 
     cout << " Manish Baphna" << (uint64_t)((dout.data)[15-count]) << endl; But nothing worked with -o3. Seems like it wants 'cout' with that particulat typecast statement ( grrrr ... :))

Though we are not stuck due to this , I am keen in finding out the root cause. Also ,are there any other dignified workarounds  other then using o2 switch or having cout in release build ?

Best Regards
-  Manish

PS : I am not very regular on this list so apologies in case I am cribbing for already discussed issue.



      Download prohibited? No problem. CHAT from any browser, without download. Go to http://in.webmessenger.yahoo.com/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]