public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/26820]  New: g++ compiler: incorrect handling of reference parameters
@ 2006-03-23  6:25 ramiller at mines dot edu
  2006-03-23  6:29 ` [Bug c++/26820] " ramiller at mines dot edu
  2006-03-23  6:30 ` pinskia at gcc dot gnu dot org
  0 siblings, 2 replies; 3+ messages in thread
From: ramiller at mines dot edu @ 2006-03-23  6:25 UTC (permalink / raw)
  To: gcc-bugs

Results of gcc -v -save-temps all-your-options source-file: 

gcc -v -save-temps all-your-options SampleExam1.cpp 
gcc: all-your-options: No such file or directory
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.3/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --with-system-zlib --enable-__cxa_atexit
--host=i386-redhat-linux
Thread model: posix
gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-54)
 /usr/lib/gcc-lib/i386-redhat-linux/3.2.3/cpp0 -lang-c++ -D__GNUG__=3
-D__DEPRECATED -D__EXCEPTIONS -v -D__GNUC__=3 -D__GNUC_MINOR__=2
-D__GNUC_PATCHLEVEL__=3 -D__GNUC_RH_RELEASE__=54 -D__GXX_ABI_VERSION=102
-D__ELF__ -Dunix -D__gnu_linux__ -Dlinux -D__ELF__ -D__unix__ -D__gnu_linux__
-D__linux__ -D__unix -D__linux -Asystem=posix -D__NO_INLINE__
-D__STDC_HOSTED__=1 -D_GNU_SOURCE -Acpu=i386 -Amachine=i386 -Di386 -D__i386
-D__i386__ -D__tune_i386__ SampleExam1.cpp SampleExam1.ii
GNU CPP version 3.2.3 20030502 (Red Hat Linux 3.2.3-54) (cpplib) (i386
Linux/ELF)
ignoring nonexistent directory "/usr/i386-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/c++/3.2.3
 /usr/include/c++/3.2.3/i386-redhat-linux
 /usr/include/c++/3.2.3/backward
 /usr/local/include
 /usr/lib/gcc-lib/i386-redhat-linux/3.2.3/include
 /usr/include
End of search list.
 /usr/lib/gcc-lib/i386-redhat-linux/3.2.3/cc1plus -fpreprocessed SampleExam1.ii
-quiet -dumpbase SampleExam1.cpp -version -o SampleExam1.s
GNU CPP version 3.2.3 20030502 (Red Hat Linux 3.2.3-54) (cpplib) (i386
Linux/ELF)
GNU C++ version 3.2.3 20030502 (Red Hat Linux 3.2.3-54) (i386-redhat-linux)
        compiled by GNU C version 3.2.3 20030502 (Red Hat Linux 3.2.3-54).
 as -V -Qy -o SampleExam1.o SampleExam1.s
GNU assembler version 2.14.90.0.4 (i386-redhat-linux) using BFD version
2.14.90.0.4 20030523

I cannot figure out how to attach the source file here, but if you need it,
please let me know.

Suppose a program contains the function 
double f1(double x_par, double y_par, double& z_par) 
{
// I have simplified the function operation here to avoid writing too many 
// unnecessary lines of code.

x_par = 3;
y_par = 1;
z_par = x_par + y_par;
return(z_par);
}

In main, I have the code:
double x = 8, y = 3, z = 1;
cout << f(x, y, z) << " " << x << y << z << endl;
cout << x << y << z << endl;

Given that z is a reference parameter, we would expect the output
4 834
834

but the actual output is
4 831
834

For some reason, the compiler is not recognizing the change to the reference
argument in that first line of code.

Thank you for your time.


-- 
           Summary: g++ compiler: incorrect handling of reference parameters
           Product: gcc
           Version: 3.2.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ramiller at mines dot edu


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


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

* [Bug c++/26820] g++ compiler: incorrect handling of reference parameters
  2006-03-23  6:25 [Bug c++/26820] New: g++ compiler: incorrect handling of reference parameters ramiller at mines dot edu
@ 2006-03-23  6:29 ` ramiller at mines dot edu
  2006-03-23  6:30 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: ramiller at mines dot edu @ 2006-03-23  6:29 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from ramiller at mines dot edu  2006-03-23 06:29 -------
Created an attachment (id=11102)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=11102&action=view)
Source code from which compiler bug was determined

I figured out how to attach the source code...


-- 


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


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

* [Bug c++/26820] g++ compiler: incorrect handling of reference parameters
  2006-03-23  6:25 [Bug c++/26820] New: g++ compiler: incorrect handling of reference parameters ramiller at mines dot edu
  2006-03-23  6:29 ` [Bug c++/26820] " ramiller at mines dot edu
@ 2006-03-23  6:30 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-03-23  6:30 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2006-03-23 06:30 -------
This is not a bug, you are misunderstanding what order stuff gets evaluated in
the following expression:
cout << f(x, y, z) << " " << x << y << z << endl;


The C++ standard leaves the order of evaluating of f(x,y,z), the load of x, y,
and z all up to the compiler and allows that order to be different at different
level of optimizations also.

This is a dup of bug 11751.

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

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


-- 

pinskia at gcc dot gnu dot org changed:

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


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


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

end of thread, other threads:[~2006-03-23  6:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-23  6:25 [Bug c++/26820] New: g++ compiler: incorrect handling of reference parameters ramiller at mines dot edu
2006-03-23  6:29 ` [Bug c++/26820] " ramiller at mines dot edu
2006-03-23  6:30 ` 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).