This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C++ extension "cast-as-lvalues": time to deprecate?


> But what, exactly, are we warning about?  Consider the following program:
>
> --------------------------------------
> #include <iostream>
>
> void foo(int&) {
>     std::cout << "foo(int&) called\n";
> }
>
> void foo(const int&) {
>     std::cout << "foo(const int&) called\n";
> }
>
> int main(int, char**) {
>     unsigned u = 0;
>     foo((int)u);
> }

Oh, ugh, I didn't know we mishandled that.  That's just a bug; the only
places we should be trying to support the cast-as-lvalue extension at this
point are those places where GCC does: the left-hand side of an assignment
statement.  It was there that I wanted to introduce the warning.

(Your example is a bug in G++ because we try to maintain the invariant that
GNU extensions do not change the meaning of valid programs.  There are
numerous places where that ideal is not achieved, but it is the ideal.)

-- Mark


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]