Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
From: Marc Roussel <roussel@henri.chem.uleth.ca>
Subject: Mysterious DEC OSF C++ compiler warning
Date: 1995/12/18	[thread overview]
Message-ID: <4b4rog$m80@holly.cc.uleth.ca> (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




             reply	other threads:[~1995-12-18  5:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1995-12-18  5:00 Marc Roussel [this message]
1995-12-18  5:00 ` Mysterious DEC OSF C++ compiler warning Morgan Deters
1995-12-19  5:00 ` Andrew Koenig
1995-12-20  5:00 ` Tim Lucia
read-only archive

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