incubator-stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Travis Vitek <vi...@roguewave.com>
Subject [PATCH] 26.valarray.transcend.stdcxx-315.cpp fails to compile on Intel C++ 10.025
Date Mon, 29 Oct 2007 21:39:25 GMT

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.

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

    [vitek@robot 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;
    }

    [vitek@robot 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.

    [vitek@robot 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)
    [vitek@robot 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; }

-- 
View this message in context: http://www.nabble.com/-PATCH--26.valarray.transcend.stdcxx-315.cpp-fails-to-compile-on-Intel-C%2B%2B-10.025-tf4714891.html#a13477604
Sent from the stdcxx-dev mailing list archive at Nabble.com.


Mime
View raw message