Travis Vitek wrote:
Apparently Intel C++ 10.025 doesn't consider a operator= to be a
copy-assignment operator if it is const, so the test fails to compile when
the compiler attempts to generate its own definition. According to 12.8 p9
and p10, this code _should_ be legal. The problem does not occur with 10.026
on Windows [I don't have access to 10.025 on Windows or 10.026 on Linux], so
I have not filed an issue with Intel.

I think you're right. I see no requirement that a user-declared
copy assignment operator be a non-const member function. I get
the same error with the latest EDG eccp 3.10 so unless I find
something we have both missed I'll let EDG know about this
(suspected) bug.

Your patch looks good to me, btw. I'll commit it shortly.

Thanks!
Martin


Here is a simple testcase and the compile result...

    [EMAIL PROTECTED] tests]$ cat t.cpp

    struct S {
        const S* const self;
        S () : self (this) { }
        S (const S &s) : self (this) { }
        void operator=(const S &s) const { }
    };

    int main () {
        S().operator=(S());
        return 0;
    }

    [EMAIL PROTECTED] tests]$ icc -V
    Intel(R) C Compiler for applications running on Intel(R) 64, Version
10.0    Build 20070613 Package ID: l_cc_c_10.0.025
    Copyright (C) 1985-2007 Intel Corporation.  All rights reserved.

    [EMAIL PROTECTED] tests]$ icc -c t.cpp
    t.cpp(2): error: implicitly generated assignment operator cannot copy:
                const member "S::self"
      struct S {
             ^
              detected during implicit generation of "S &S::operator=(const
S &)" at line 10

    compilation aborted for t.cpp (code 2)
[EMAIL PROTECTED] tests]$
Here is a simple patch to avoid the issue.

Index: 26.valarray.transcend.stdcxx-315.cpp
===================================================================
--- 26.valarray.transcend.stdcxx-315.cpp        (revision 589749)
+++ 26.valarray.transcend.stdcxx-315.cpp        (working copy)
@@ -48,7 +48,7 @@
     ~S () { pass = pass && this == self; }
     operator double () const { pass = pass && this == self; return 1.0; }

-    void operator=(const S &s) const {
+    void operator=(const S &s) {
         pass = pass && &s == s.self && this == self;
     }
     S operator- () const { pass = pass && this == self; return *this; }


Reply via email to