This is the mail archive of the gcc-bugs@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]

[Bug c++/13384] New: error: non-lvalue in assignment - message a little misleading for C++


The code below :

struct C
{
    int a;

    C()
      : a(1)
    {
    }
};

template<typename T> void func()
{
    T() = T();
}

int main()
{
    func<C>();
    func<int>();
}

Produces the error message

"error: non-lvalue in assignment"

As you can see, the first instantiation (func<C>) is quite happy to call assign
on an rvalue.  The second (func<int>) uses the built-in operator= which does not
allow assignment to non-lvalue.  While the message is accurate, it would be IMHO
better if the message was:

"error: non-lvalue in built-in assignment" (suggestions welcome)

This message geneaology is probably from the C compiler and is a little
misleading for C++.

-- 
           Summary: error: non-lvalue in assignment - message a little
                    misleading for C++
           Product: gcc
           Version: 3.3.1
            Status: UNCONFIRMED
          Severity: minor
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gianni at mariani dot ws
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13384


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