C4239 - why here?
Hi all!
I understand the rationale behind the warning 4239 (I think :-))
(warning C4239: nonstandard extension used : 'argument' : conversion from X
to Y A reference that is not to 'const' cannot be bound to a non-lvalue;
assigment operator takes a reference to non-const)
However, in this situation:
void F(X& x)
I get it for code like this:
F(X());
And I find it perfectly fine. So I have to use pragma's or split this in two
lines like this:
{ X x;
F(x); }
(With brackets, x gest destroyed immediately after the call; without, it
goes out of scope later, which sometimes isn't good; but OK, this is not my
man point)
Anyhow... Yuck!
Anybody has a comment on this isue? (Especially this: what "const" has to do
with anything here!?)
Goran.
.
Relevant Pages
- Re: Anders Hejlsberg comment on immutable objects
... >explicit interface implementation exists is so an interface name can class ... Improper implicit conversions constitute a nasty ... >> With value types, the variable's value is the object, not a reference ... Consider the affects of our different views on a const ... (microsoft.public.dotnet.languages.csharp) - Re: handle/reference?
... > void MyFunction(const HANDLE myhandle) ... > void MyFunction ... If you pass a handle by reference, ... const reference or const, you're inhibiting such changes. ... (microsoft.public.dotnet.languages.vc) - Re: cast to non-const reference of a functions return object
... >recently i discovered a memory leak in our code; ... I think you mean "use of a dangling reference" rather than "memory ... casting a const return object from a function to a non-const reference ... (comp.lang.cpp) - Re: Another C# critique (major rewrite!)
... it would be a different kind of const. ... > pointer, and the vtable to point to the Type. ... needs answering most specifically would be is a reference a literal pointer ... >>Currently I'm thinkg about security and control. ... (microsoft.public.dotnet.languages.csharp) - Re: operater= overload problem
... and added const? ... Would requesting reference material be ... > type unsigned int, and indeed all built-in types, none of these apply. ... > Really the only reason to ever use pass by reference with built-in types is ... (microsoft.public.vc.mfc) |
|