Topic: Compilers disagree about assigment of lvalue?


Author: len@migration.com (Len Lattanzi)
Date: 1998/04/16
Raw View
On 13 Apr 1998 15:49:44 GMT, Tom McKearney <no@spam.com> wrote:
>Phil Romig wrote in message <6gg31r$iit@crcnis3.unl.edu>...
>>I have two different compilers (egcs and HP's aCC) which disagree about the
>*aCC* !!
>
>That's all that I needed to hear.  That compiler is definitely behind the
>standard.  I am using it at work myself, and I find it quite frustrating.
>The version we have (which we _just_ purchased) doesn't even support
>namespaces.
>
>I would guess that aCC is your problem.
I haven't found the original post so I can't comment on egcs Vs. aCC
however I'd like to make it clear that aCC does support namespaces,
using directives and using declarations. Because V1.0 went out with
namespaces, later releases have not enabled namespace std to avoid
binary incompatibility.

--
Len Lattanzi Migration Software Systems, Ltd
try <len@migration.com>
catch 1-408-452-0527


[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: jkanze@otelo.ibmmail.com
Date: 1998/04/09
Raw View
In article <6gg31r$iit@crcnis3.unl.edu>,
  romig@cse.unl.edu (Phil Romig) wrote:
>
> I have two different compilers (egcs and HP's aCC) which disagree about the
> validity of the following code:
>
>     string test2 = a_bar->my_foo().data;
>
> where a_bar->my_foo() returns an object which has a data member data of
> type char*  (a complete program is at the end of this post).

In your program, at least, the member data does NOT have type char*,
but type char[10].

According to the FDIS, "An lvalue or rvalue of type 'array of N T' or
'array of unknown bound of T' can be converted to an rvalue of type
'pointer to T.', which would tend to confirm the legality of your
program.  On the other hand, in the CD2, the "or rvalue" is missing,
so the conversion was not legal until a couple of months ago; it is
not really surprising that a commercial compiler doesn't implement
it yet.

(I think that this change goes back to a problem in C, where indexing
into the array didn't work, because the expresion a[i] requires a
pointer for a, and the conversion array to pointer didn't work on
a non-lvalue.)

--
James Kanze    +33 (0)1 39 23 84 71    mailto: kanze@gabi-soft.fr
        +49 (0)69 66 45 33 10    mailto: jkanze@otelo.ibmmail.com
GABI Software, 22 rue Jacques-Lemercier, 78000 Versailles, France
Conseils en informatique orient   e objet --
              -- Beratung in objektorientierter Datenverarbeitung

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: "Tom McKearney" <no@spam.com>
Date: 1998/04/13
Raw View
Phil Romig wrote in message <6gg31r$iit@crcnis3.unl.edu>...
>I have two different compilers (egcs and HP's aCC) which disagree about the
*aCC* !!

That's all that I needed to hear.  That compiler is definitely behind the
standard.  I am using it at work myself, and I find it quite frustrating.
The version we have (which we _just_ purchased) doesn't even support
namespaces.

I would guess that aCC is your problem.

Tom McKearney



[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: romig@cse.unl.edu (Phil Romig)
Date: 1998/04/08
Raw View
I have two different compilers (egcs and HP's aCC) which disagree about the
validity of the following code:

    string test2 = a_bar->my_foo().data;

where a_bar->my_foo() returns an object which has a data member data of
type char*  (a complete program is at the end of this post).

g++ does not have a problem, but the commercial compiler tells me:
  "Error #409: Cannot convert a non-lvalue to a pointer."

Both compilers allow assignment of char* to a string.

Which compiler is correct?  I have a feeling that g++ is, because I can't
see anything wrong with what I'm doing.

Does anyone have any idea what HP's compiler is complaining about?  Why
does it need an lvalue on the rhs of the assignment?

Any help would be welcome.

thanks
Phil
romig@cse.unl.edu



//////////////////////////////////////////////////////////////////////
// A toy program which demonstrates what I'm talking about.
// Don't worry about what it does.  Just pretend I have a good
// reason for doing what I'm doing.
//////////////////////////////////////////////////////////////////////
#include <string>

class foo {
 public:
  char data[10];
};

class bar {
 public:
   foo a_foo;
   foo my_foo() { return a_foo; }
};

int main () {
  bar* a_bar = new bar;

  char* test1 = a_bar->my_foo().data;  // Works fine under both aCC and g++.
  string test2 = a_bar->my_foo().data; // Compiler error under aCC.
}
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]