incubator-stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Travis Vitek (JIRA)" <j...@apache.org>
Subject [jira] Issue Comment Edited: (STDCXX-605) [IBM XLC++] errors compiling dynatype.cpp
Date Tue, 04 Dec 2007 18:05:45 GMT

    [ https://issues.apache.org/jira/browse/STDCXX-605?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12546445
] 

vitek edited comment on STDCXX-605 at 12/4/07 10:04 AM:
---------------------------------------------------------------


This appears to be a compiler bug. Here is a simple testcase.

[vitek@rimple vitek]$ cat t.cpp && xlC -c t.cpp

struct A
{
    template <class T>
    operator T& ();
};

int main ()
{
    A a;
    (int)a;
    return 0;
}
"t.cpp", line 11.10: 1540-0216 (S) An expression of type "A" cannot be converted to type "int".
[vitek@rimple vitek]$ 

Making an explicit call to `a.operator int& ()' works, as does a cast to `int&' before
the cast to `int'. It appears that the compiler isn't seeing that it can get an `int' by applying
one of the conversion operators.

Possible workarounds are to explicitly call the conversion operator, do an additional cast,
or change the conversion operator to be an exact match. i.e. `operator T () const'.

      was (Author: vitek):
    
This appears to be a compiler bug. Here is a simple testcase.

[vitek@rimple examples]$ cat t.cpp && xlCcore -g -q64 t.cpp

template <class T>
T& get ()
{
    static T v = T();
    return v;
}

struct A
{
    template <class T>
    operator const T& () const {
        return get<T>();
    }
};

int main ()
{
    A a;
    (int)a;
    return 0;
}
"t.cpp", line 20.10: 1540-0216 (S) An expression of type "A" cannot be converted to type "int".

Making an explicit call to `a.operator const int& ()' works, as does a cast to `const
int&' before the cast to `int'. It appears that the compiler isn't seeing that it can
get an `int' by applying one of the conversion operators.

Possible workarounds are to explicitly call the conversion operator, do an additional cast,
or change the conversion operator to be an exact match. i.e. `operator T () const'.
  
> [IBM XLC++] errors compiling dynatype.cpp
> -----------------------------------------
>
>                 Key: STDCXX-605
>                 URL: https://issues.apache.org/jira/browse/STDCXX-605
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: Examples
>    Affects Versions: 4.2.0
>         Environment: XLC++ 6.0 through 9.0/AIX 5.3
>            Reporter: Martin Sebor
>            Assignee: Travis Vitek
>             Fix For: 4.2.1
>
>         Attachments: stdcxx-605.patch
>
>
> The dynatype.cpp example program fails to compile with IBM XLC++ 9.0 on AIX with ethe
following errors:
> xlCcore_r -c -I$(TOPDIR)/include/ansi    -I$(TOPDIR)/include -I$(BUILDDIR)/include -I$(TOPDIR)/examples/include
 -O -Q     -qtemplateregistry=dynatype.ti $(TOPDIR)/examples/tutorial/dynatype.cpp
> "$(TOPDIR)/examples/tutorial/dynatype.cpp", line 203.27: 1540-0216 (S) An expression
of type "dynatype" cannot be converted to type "int".
> "$(TOPDIR)/examples/tutorial/dynatype.cpp", line 209.30: 1540-0216 (S) An expression
of type "dynatype" cannot be converted to type "double".
> "$(TOPDIR)/examples/tutorial/dynatype.cpp", line 215.30: 1540-0216 (S) An expression
of type "dynatype" cannot be converted to type "double".
> "$(TOPDIR)/examples/tutorial/dynatype.cpp", line 222.35: 1540-0216 (S) An expression
of type "dynatype" cannot be converted to type "const char *".
> "$(TOPDIR)/examples/tutorial/dynatype.cpp", line 228.35: 1540-0216 (S) An expression
of type "dynatype" cannot be converted to type "const char *".
> "$(TOPDIR)/examples/tutorial/dynatype.cpp", line 238.28: 1540-0216 (S) An expression
of type "dynatype" cannot be converted to type "char".
> gmake: *** [dynatype.o] Error 1

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message