public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/25411]  New: Optimization with -O2 -finline-functions gives wrong code
@ 2005-12-14 13:39 hans dot ekkehard dot plesser at umb dot no
  2005-12-14 13:45 ` [Bug c++/25411] " hans dot ekkehard dot plesser at umb dot no
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: hans dot ekkehard dot plesser at umb dot no @ 2005-12-14 13:39 UTC (permalink / raw)
  To: gcc-bugs

A test for functor expressions in the Vigra library testsuite gives erroneous
results if compiled with -O2 -finline-functions.  No problem occurs if either
option is dropped.  The error occurs as well with g++ 4.0.0, but not with
3.4.3. The error occurs under Tru64 V5.1B on an AlphaServer, but not under
Linux on i686 (g++ 4.0.0).

The program in question is

#include <iostream>
#include "vigra/functorexpression.hxx"
#include "vigra/rgbvalue.hxx"

using namespace vigra::functor;

int main()
{
  vigra::RGBValue<int> data[] = { vigra::RGBValue<int>(0),
vigra::RGBValue<int>(1) }; 
  vigra::RGBValue<int> sum(0);
  int count = 0;

  for ( int j = 0 ; j < 2 ; ++j )
    std::cerr << "data[" << j << "]: " << data[j] << std::endl;

  std::for_each(data, data+2, 
                (
                 Var(count) += Param(1) ,
                 Var(sum) += Arg1() 
                 ));

  std::cerr << "count: " << count 
            << "\nsum: " << sum 
            << std::endl;

  return 0;
}

The expected output is

data[0]: (0, 0, 0)
data[1]: (1, 1, 1)
count: 2
sum: (1, 1, 1)

If compiled with -O2 -finline-functions, the following is produced:

data[0]: (0, 0, 0)
data[1]: (1, 1, 1)
count: 0
sum: (3, 1, 1)

If the two items in the comma-expression that forms the third argument of
std::for_each() are exchanged, correct code is produced with the
-finline-functions option in place.

I will be happy to supply header files or the preprocessor output on request.

Hans E Plesser


-- 
           Summary: Optimization with -O2 -finline-functions gives wrong
                    code
           Product: gcc
           Version: 4.0.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: hans dot ekkehard dot plesser at umb dot no
 GCC build triplet: alphaev7-dec-osf5.1b
  GCC host triplet: alphaev7-dec-osf5.1b
GCC target triplet: alphaev7-dec-osf5.1b


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


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

* [Bug c++/25411] Optimization with -O2 -finline-functions gives wrong code
  2005-12-14 13:39 [Bug c++/25411] New: Optimization with -O2 -finline-functions gives wrong code hans dot ekkehard dot plesser at umb dot no
@ 2005-12-14 13:45 ` hans dot ekkehard dot plesser at umb dot no
  2005-12-14 15:54 ` rguenth at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: hans dot ekkehard dot plesser at umb dot no @ 2005-12-14 13:45 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from hans dot ekkehard dot plesser at umb dot no  2005-12-14 13:45 -------
Created an attachment (id=10485)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=10485&action=view)
Preprocessed reproducer for optimize bug

This is the complete preprocessed source code for bug 25411.

g++ -O2 -finline-functions Bug25411.ii -o Bug25411

yields an executable that causes the erroneous output reported under Tru64.

Hans E Plesser


-- 


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


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

* [Bug c++/25411] Optimization with -O2 -finline-functions gives wrong code
  2005-12-14 13:39 [Bug c++/25411] New: Optimization with -O2 -finline-functions gives wrong code hans dot ekkehard dot plesser at umb dot no
  2005-12-14 13:45 ` [Bug c++/25411] " hans dot ekkehard dot plesser at umb dot no
@ 2005-12-14 15:54 ` rguenth at gcc dot gnu dot org
  2005-12-15  8:41 ` falk at debian dot org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2005-12-14 15:54 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from rguenth at gcc dot gnu dot org  2005-12-14 15:54 -------
Cannot reproduce with gcc (GCC) 4.1.0 20050916 (experimental) on x86_64-linux.


-- 


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


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

* [Bug c++/25411] Optimization with -O2 -finline-functions gives wrong code
  2005-12-14 13:39 [Bug c++/25411] New: Optimization with -O2 -finline-functions gives wrong code hans dot ekkehard dot plesser at umb dot no
  2005-12-14 13:45 ` [Bug c++/25411] " hans dot ekkehard dot plesser at umb dot no
  2005-12-14 15:54 ` rguenth at gcc dot gnu dot org
@ 2005-12-15  8:41 ` falk at debian dot org
  2005-12-16 11:50 ` hans dot ekkehard dot plesser at umb dot no
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: falk at debian dot org @ 2005-12-15  8:41 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from falk at debian dot org  2005-12-15 08:41 -------
I cannot reproduce this on alphaev68-linux with 4.0.3 20051201 (prerelease),
4.1.0 20051124 (prerelease), or 4.2.0 20051124 (experimental). Could you
perhaps try a newer version (4.0.2) or even better a recent snapshot?


-- 

falk at debian dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING


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


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

* [Bug c++/25411] Optimization with -O2 -finline-functions gives wrong code
  2005-12-14 13:39 [Bug c++/25411] New: Optimization with -O2 -finline-functions gives wrong code hans dot ekkehard dot plesser at umb dot no
                   ` (2 preceding siblings ...)
  2005-12-15  8:41 ` falk at debian dot org
@ 2005-12-16 11:50 ` hans dot ekkehard dot plesser at umb dot no
  2005-12-16 21:34 ` falk at debian dot org
  2006-01-01  5:26 ` pinskia at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: hans dot ekkehard dot plesser at umb dot no @ 2005-12-16 11:50 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from hans dot ekkehard dot plesser at umb dot no  2005-12-16 11:50 -------
(In reply to comment #3)
> I cannot reproduce this on alphaev68-linux with 4.0.3 20051201 (prerelease),
> 4.1.0 20051124 (prerelease), or 4.2.0 20051124 (experimental). Could you
> perhaps try a newer version (4.0.2) or even better a recent snapshot?
> 

The bug occurs under release version 4.0.2 on alphaev7-dec-osf5.1b.

It does NOT occur under 
gcc version 4.0.3 20051208 (prerelease)
gcc version 4.1.0 20051209 (prerelease)

I have not managed a complete build of 4.2.0.

Hans


-- 


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


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

* [Bug c++/25411] Optimization with -O2 -finline-functions gives wrong code
  2005-12-14 13:39 [Bug c++/25411] New: Optimization with -O2 -finline-functions gives wrong code hans dot ekkehard dot plesser at umb dot no
                   ` (3 preceding siblings ...)
  2005-12-16 11:50 ` hans dot ekkehard dot plesser at umb dot no
@ 2005-12-16 21:34 ` falk at debian dot org
  2006-01-01  5:26 ` pinskia at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: falk at debian dot org @ 2005-12-16 21:34 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from falk at debian dot org  2005-12-16 21:34 -------
(In reply to comment #4)
> It does NOT occur under 
> gcc version 4.0.3 20051208 (prerelease)

Okay, so let's close it, then.


-- 

falk at debian dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |RESOLVED
         Resolution|                            |FIXED


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


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

* [Bug c++/25411] Optimization with -O2 -finline-functions gives wrong code
  2005-12-14 13:39 [Bug c++/25411] New: Optimization with -O2 -finline-functions gives wrong code hans dot ekkehard dot plesser at umb dot no
                   ` (4 preceding siblings ...)
  2005-12-16 21:34 ` falk at debian dot org
@ 2006-01-01  5:26 ` pinskia at gcc dot gnu dot org
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-01-01  5:26 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.0.3


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



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

end of thread, other threads:[~2006-01-01  5:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-12-14 13:39 [Bug c++/25411] New: Optimization with -O2 -finline-functions gives wrong code hans dot ekkehard dot plesser at umb dot no
2005-12-14 13:45 ` [Bug c++/25411] " hans dot ekkehard dot plesser at umb dot no
2005-12-14 15:54 ` rguenth at gcc dot gnu dot org
2005-12-15  8:41 ` falk at debian dot org
2005-12-16 11:50 ` hans dot ekkehard dot plesser at umb dot no
2005-12-16 21:34 ` falk at debian dot org
2006-01-01  5:26 ` pinskia 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).