Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
* Mysterious DEC OSF C++ compiler warning
@ 1995-12-18  5:00 Marc Roussel
  1995-12-18  5:00 ` Morgan Deters
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Marc Roussel @ 1995-12-18  5:00 UTC (permalink / raw)


Here's a simple program for which the DEC OSF C++ compiler generates a (to me)
mysterious warning:

// foo.h:
class junk
        { double a;
          public:
          junk(void) {};
          junk(double x) { a = x;};
          junk & operator = (junk & x) { a = x.a; return(*this);};
        };

// foo.c
#include <iostream.h>
#include <math.h>
#include "foo.h"


main()
{
    junk x;

    x = junk(2);
}

The warning is

foo.c:10: warning: In this statement, the initialization of a non-const
reference requires a temporary for "junk(2)".

Programs which generate this warning nevertheless appear to execute correctly.
Is the DEC compiler getting excited about nothing?  Is it warning me about
nonportable usage?  Bad style?  What's the scoop?  If I'm doing something
wrong, is there a reasonably easy workaround?  Note that the line which reads
"x=junk(2)" can be replaced with "x=2" and still generates a similar warning.
Finally, I should mention that code like this generates no warnings with the
somewhat old Borland compiler on my home machine.

Thanks in advance for any help you can offer.
-- 
					Marc R. Roussel
					(roussel@henri.chem.uleth.ca)
					Department of Chemistry
					University of Lethbridge




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

end of thread, other threads:[~1995-12-20  5:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1995-12-18  5:00 Mysterious DEC OSF C++ compiler warning Marc Roussel
1995-12-18  5:00 ` Morgan Deters
1995-12-19  5:00 ` Andrew Koenig
1995-12-20  5:00 ` Tim Lucia

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox