You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stdcxx.apache.org by "Martin Sebor (JIRA)" <ji...@apache.org> on 2007/10/22 07:00:50 UTC

[jira] Created: (STDCXX-605) [XLC++ 9.0] errors compiling dynatype.cpp

[XLC++ 9.0] 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: trunk
         Environment: XLC++ 9.0/AIX 5.3
            Reporter: Martin Sebor
             Fix For: 4.2.1


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.


[jira] Issue Comment Edited: (STDCXX-605) [IBM XLC++] errors compiling dynatype.cpp

Posted by "Travis Vitek (JIRA)" <ji...@apache.org>.
    [ 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.


[jira] Commented: (STDCXX-605) [IBM XLC++] errors compiling dynatype.cpp

Posted by "Martin Sebor (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/STDCXX-605?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12549616 ] 

Martin Sebor commented on STDCXX-605:
-------------------------------------

I assume (1) is because of the compiler bug?

For (2) yes, if we can't have static_cast<T>(v) because of the XLC++ bug I'd rather see static_cast<const T&>(v). The problem, as I understand it, is that we're invoking the conversion operator on a non-const dynatype object and thus operator T&() rather than operator const T&() const is being invoked. I wonder if there's a way to detect that the caller is invoking a const T& cast and dispatch to a const member function instead...

(3) Yes. I'm saying I think the output of the example should match the code (and use '\n' instead of std::endl).

(4) We should try. Is the difference due to unspecified behavior or another compiler bug? (Have fun reading the relevant sections of the standard! ;-)

> [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.


[jira] Issue Comment Edited: (STDCXX-605) [IBM XLC++] errors compiling dynatype.cpp

Posted by "Travis Vitek (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/STDCXX-605?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12549576 ] 

vitek edited comment on STDCXX-605 at 12/7/07 2:23 PM:
--------------------------------------------------------------

New and improved. Hopefully approved.

2007-12-06  Travis Vitek  <vi...@roguewave.com> 

	STDCXX-605 
	* examples/tutorial/dynatype.cpp (main): Explicit cast to
	correct type to avoid issues on IBM VisualAge C++. Use
	static_cast for consistency with existing example code.

      was (Author: vitek):
    New and improved. Hopefully approved.

2007-12-06  Travis Vitek  <vi...@roguewave.com> 

	STDCXX-605 
	* tutorial/dynatype.cpp (main): Explicit cast to correct
	type to avoid issues on IBM VisualAge C++. Use static_cast
	for consistency with other parts of the example.
  
> [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.


[jira] Commented: (STDCXX-605) [IBM XLC++] errors compiling dynatype.cpp

Posted by "Travis Vitek (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/STDCXX-605?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12550251 ] 

Travis Vitek commented on STDCXX-605:
-------------------------------------

1. Yes, all of this is because of the compiler bug. As it turns out, a similar problem exists for some builds on VC7.1.
2. I think I can do it, but the only way I can come up with involves quite a bit of template metaprogramming and that adds a lot of complication to the example. Perhaps I'm persuing the wrong method? If not, I'd hope that we could come up with a simpler solution. I'd almost prefer to use named methods for doing the conversions.
3. Fine.
4. I'll file another bug on that issue. I've wasted enough time on this particular goose-chase already.


> [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.


[jira] Commented: (STDCXX-605) [IBM XLC++] errors compiling dynatype.cpp

Posted by "Travis Vitek (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/STDCXX-605?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12549606 ] 

Travis Vitek commented on STDCXX-605:
-------------------------------------

1. The original code casted to values. We can't cast to values, unless you'd like to cast to a reference first, then cast the result to a value. Of course that is already happening behind the scenes, so I see no reason to be so explicit unless required.

2. I'm assuming that you'd rather see `static_cast<const int&>(v1)' over `static_cast<int&>(v1)'. If that is the case, then yes, I'd like to cast to const references also. Unfortunately you can't because `const T' is a different type than `T' when it comes to templates. The non-const template conversion operator gets invoked, and the dynatype tries to look itself up in the map<const dynatype*, const T>, which fails, and throws an exception. I could const_cast the dynatype, then cast that, but that is even more hideous that what I've got now...

        std::cout << "double (v2 = v1) = "
                  << static_cast<const double&>(const_cast<const dynatype&>(v2))
                  << std::endl;

I started to write named helper methods (get<>, get_ref<>, get_cref<>) to retrieve the value after applying the cast, but that seemed wrong because the `dynatype' is supposed to look and feel just like an object of type T, and adding special functions to make it behave that way seems wrong.

3. Are you saying you want me to modify the output spew to match the code, like so...

        std::cout << "static_cast<double&>(v2 = v1) = "
                  << static_cast<double&>(v2) << std::endl;

4. The output is slightly different between AIX and Linux. Linux/GCC appear to evaluate all of the arguments before calling the stream functions, and AIX/VisualAgeC++ seem to invoke the arguments as they are needed. This causes a diff in the output, which will probably be flagged as a failure. Should I fix this also?


> [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.


[jira] Updated: (STDCXX-605) [IBM XLC++] errors compiling dynatype.cpp

Posted by "Travis Vitek (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/STDCXX-605?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Travis Vitek updated STDCXX-605:
--------------------------------

    Attachment: stdcxx-605.patch


2007-11-27  Travis Vitek  <vi...@roguewave.com>

	STDCXX-605
	* tutorial/dynatype.cpp: Change const conversion operator
	overload to return by value to avoid compiler bug with IBM
	VisualAge C++.


> [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.


[jira] Updated: (STDCXX-605) [IBM XLC++] errors compiling dynatype.cpp

Posted by "Travis Vitek (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/STDCXX-605?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Travis Vitek updated STDCXX-605:
--------------------------------

    Attachment: stdcxx-605-out.patch

The update output is now attached as a separate patch.

> [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-out.patch, stdcxx-605-v1.patch, stdcxx-605-v2.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.


[jira] Assigned: (STDCXX-605) [IBM XLC++] errors compiling dynatype.cpp

Posted by "Martin Sebor (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/STDCXX-605?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Martin Sebor reassigned STDCXX-605:
-----------------------------------

    Assignee: Travis Vitek

> [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
>
>
> 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.


[jira] Updated: (STDCXX-605) [IBM XLC++] errors compiling dynatype.cpp

Posted by "Travis Vitek (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/STDCXX-605?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Travis Vitek updated STDCXX-605:
--------------------------------

    Attachment:     (was: stdcxx-605.patch)

> [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
>
>
> 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.


[jira] Commented: (STDCXX-605) [IBM XLC++] errors compiling dynatype.cpp

Posted by "Martin Sebor (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/STDCXX-605?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12549268 ] 

Martin Sebor commented on STDCXX-605:
-------------------------------------

I don't think the patch is appropriate. The comment above the function says: "retrieve a const reference to the concrete type from an instance of dynatype throws std::bad_cast if the types don't match exactly." It seems that changing the return type from const T& to T might change the semantics of the function in some cases by introducing a conversion where one wouldn't otherwise be allowed. It's also inefficient. I realize this is just an example, but it's an example of a generic container that should be efficient.

Btw., do we have an External issue for this bug (and have we opened a PMR with IBM for it)? I'd like to link them together so we can track the vendor's progress on their bug without cluttering this issue.

> [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.


[jira] Commented: (STDCXX-605) [IBM XLC++] errors compiling dynatype.cpp

Posted by "Martin Sebor (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/STDCXX-605?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12557880#action_12557880 ] 

Martin Sebor commented on STDCXX-605:
-------------------------------------

Travis, after you've confirmed that your change (http://svn.apache.org/viewvc?view=rev&revision=610576) fixes the problem in nightly builds we need to remember to merge it to 4.2.1 and update the xfail file: http://svn.apache.org/repos/asf/incubator/stdcxx/trunk/etc/config/xfail.txt

> [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-out.patch, stdcxx-605-v1.patch, stdcxx-605-v2.patch, stdcxx-605-v3.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.


[jira] Commented: (STDCXX-605) [IBM XLC++] errors compiling dynatype.cpp

Posted by "Martin Sebor (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/STDCXX-605?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12551653 ] 

Martin Sebor commented on STDCXX-605:
-------------------------------------

Hmmm. I tried to change the patch to show you what I meant with the const but I'm just getting an exception. I guess I don't understand how it works... Why can't one overload of retrieve be const and the other non-const, like this:

    template <class T> T& retrieve (T*);
    template <class T> const T& retrieve (const T*) const;

I was hoping to then define the conversion operators like so:

    template <class T> operator T& () { return retrieve ((T*)0); }
    template <class T> operator const T& () const { return retrieve ((T*)0); }

But when I do this and run it I get this on stdout:

    static_cast<const int&>(v1 = 1) = exception


> [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.


[jira] Updated: (STDCXX-605) [IBM XLC++] errors compiling dynatype.cpp

Posted by "Travis Vitek (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/STDCXX-605?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Travis Vitek updated STDCXX-605:
--------------------------------

    Attachment: stdcxx-605-v2.patch
                stdcxx-605-v1.patch

In the failure you mention, the conversion we want is to `const int&'. The conversion operator that gets invoked is the non-const `operator T&'  with 'T' being 'const int'. That conversion operator calls the non-const retrieve(), which keeps the const and looks in the static dynatype::map<const int> for a value. We should be looking in dynatype::map<int>, but the const is not being stripped.

Consider the following...

struct S
{
private:
    template <class T> int g (T*) { return 0; }
    template <class T> int g (const T*) const { return 1; }
public:
    template <class T> int f () { return g ((T*)0); }
};

int main ()
{
    const int a = S().f<int>();
    const int b = S().f<const int>();

    return (a << 1) | b;
}

I believe that the expected result is 0. When compiling the S().f<const int>(), I see a few candidate functions for overload resolution. Given that the overload resolution system treats member functions as if they were free functions with a correctly cv-qualified implicit object parameter, the candidates would seem to be

    int S_g(S&, int*);
    int S_g(S&, const int*);

from the first template, and 

    int S_g(const S&, int*);
    int S_g(const S&, const int*);

from the second. The actual type of the call is

    ??? S_g(S&, const int*);

So the best match is easily selected, and the result is a call to the non-const 'g' template, which leaves the const on the template type T instead of stripping it like we want.

Continuing with the example, I see a few options. We could make both 'g' overloads share the same constness. If we make them have the same constness, then the overload resolution chooses the best match based on the explicit parameter type, and then discards const as we want. The disadvantage of this is that we would either have two const overloads of 'g' [which you didn't appear to like], or we can have two non-const overloads and cast away const when calling from a const member function. A third option would be to make both 'g' overloads into non-member functions that takes const S* [essentially the same as making both members const], but that would require some code rearranging.

Personally I thought that the two const retrieve() overloads was the simplest and cleanest solution [stdcxx-605-v2.patch]. The most recent patch involves changing fewer lines of code in the example, but it leaves a nasty static/const cast [stdcxx-605-v1.patch].

> [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-v1.patch, stdcxx-605-v2.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.


[jira] Updated: (STDCXX-605) [IBM XLC++] errors compiling dynatype.cpp

Posted by "Travis Vitek (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/STDCXX-605?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Travis Vitek updated STDCXX-605:
--------------------------------

    Patch Info: [Patch Available]

> [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.


[jira] Updated: (STDCXX-605) [IBM XLC++ 9.0] errors compiling dynatype.cpp

Posted by "Martin Sebor (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/STDCXX-605?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Martin Sebor updated STDCXX-605:
--------------------------------

    Summary: [IBM XLC++ 9.0] errors compiling dynatype.cpp  (was: [XLC++ 9.0] errors compiling dynatype.cpp)

> [IBM XLC++ 9.0] 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: trunk
>         Environment: XLC++ 9.0/AIX 5.3
>            Reporter: Martin Sebor
>             Fix For: 4.2.1
>
>
> 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.


[jira] Commented: (STDCXX-605) [IBM XLC++] errors compiling dynatype.cpp

Posted by "Travis Vitek (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/STDCXX-605?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12556714#action_12556714 ] 

Travis Vitek commented on STDCXX-605:
-------------------------------------

Dandy.

> [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-out.patch, stdcxx-605-v1.patch, stdcxx-605-v2.patch, stdcxx-605-v3.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.


[jira] Updated: (STDCXX-605) [IBM XLC++] errors compiling dynatype.cpp

Posted by "Travis Vitek (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/STDCXX-605?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Travis Vitek updated STDCXX-605:
--------------------------------

    Attachment: stdcxx-605.patch

Thank you Martin for pointing me in the right direction here. This fix is fairly simple and makes me happy.

2007-12-12  Travis Vitek  <vi...@roguewave.com> 

	STDCXX-605 
	* examples/tutorial/dynatype.cpp: Add overloaded method to
	discard const to avoid looking for value in wrong map when
	non-const conversion operator is used with a const type T.
	(main): Display text and converted value in two seperate
	statements so we can guarantee that output is generated the
	same on all compilers. Add a return 0 for correctness.
	* examples/tutorial/out/dynatype.out: Update output file
	to match expected output format.

> [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.


[jira] Commented: (STDCXX-605) [IBM XLC++] errors compiling dynatype.cpp

Posted by "Martin Sebor (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/STDCXX-605?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12556723#action_12556723 ] 

Martin Sebor commented on STDCXX-605:
-------------------------------------

Do you want to try to commit it now that you have commit privs?

> [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-out.patch, stdcxx-605-v1.patch, stdcxx-605-v2.patch, stdcxx-605-v3.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.


[jira] Updated: (STDCXX-605) [IBM XLC++] errors compiling dynatype.cpp

Posted by "Travis Vitek (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/STDCXX-605?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Travis Vitek updated STDCXX-605:
--------------------------------

    Attachment: stdcxx-605.patch

New and improved. Hopefully approved.

2007-12-06  Travis Vitek  <vi...@roguewave.com> 

	STDCXX-605 
	* tutorial/dynatype.cpp (main): Explicit cast to correct
	type to avoid issues on IBM VisualAge C++. Use static_cast
	for consistency with other parts of the example.

> [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.


[jira] Commented: (STDCXX-605) [IBM XLC++] errors compiling dynatype.cpp

Posted by "Travis Vitek (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/STDCXX-605?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12546445 ] 

Travis Vitek commented on STDCXX-605:
-------------------------------------


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
>
>
> 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.


[jira] Issue Comment Edited: (STDCXX-605) [IBM XLC++] errors compiling dynatype.cpp

Posted by "Martin Sebor (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/STDCXX-605?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12551653 ] 

sebor edited comment on STDCXX-605 at 12/13/07 4:22 PM:
---------------------------------------------------------------

Hmmm. I tried to change the patch to show you what I meant with the const but I'm just getting an exception. I guess I don't understand how it works... Why can't one overload of retrieve be const and the other non-const, like this:

    template <class T> T& retrieve (T*);
    template <class T> const T& retrieve (const T*) const;

I was hoping to then define the conversion operators like so:

    template <class T> operator T& () { return retrieve ((T*)0); }
    template <class T> operator const T& () const { return retrieve ((const T*)0); }

But when I do this and run it I get this on stdout:

    static_cast<const int&>(v1 = 1) = exception


      was (Author: sebor):
    Hmmm. I tried to change the patch to show you what I meant with the const but I'm just getting an exception. I guess I don't understand how it works... Why can't one overload of retrieve be const and the other non-const, like this:

    template <class T> T& retrieve (T*);
    template <class T> const T& retrieve (const T*) const;

I was hoping to then define the conversion operators like so:

    template <class T> operator T& () { return retrieve ((T*)0); }
    template <class T> operator const T& () const { return retrieve ((T*)0); }

But when I do this and run it I get this on stdout:

    static_cast<const int&>(v1 = 1) = exception

  
> [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.


[jira] Updated: (STDCXX-605) [IBM XLC++] errors compiling dynatype.cpp

Posted by "Travis Vitek (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/STDCXX-605?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Travis Vitek updated STDCXX-605:
--------------------------------

    Attachment: stdcxx-605.patch

Updated patch again.

I could get away with only one of the overloads being const. I went ahead and made both of them non-const and now call them from the non-const conversion operator. The const conversion operator does just what it always did, it casts away const and calls the other conversion operator. I think this resolves both of your issues, and reduces the footprint of the changes.

According to the style guide, there isn't supposed to be a space between a template parameter list and an opening paren, so I have omitted them in the code that I have added. There is existing code in this example that has whitespace there, I have opted to leave the existing code as-is.




> [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.


[jira] Commented: (STDCXX-605) [IBM XLC++] errors compiling dynatype.cpp

Posted by "Martin Sebor (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/STDCXX-605?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12549587 ] 

Martin Sebor commented on STDCXX-605:
-------------------------------------

I think this should work.

One question though: do we need to cast to references instead of values? If we do, I'd rather it be to const references if possible since the objects aren't being modified. In any case, we should probably also change the output of the example to look like the code (and, while you're there, replace std::endl with '\n' for efficiency).

> [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.


[jira] Updated: (STDCXX-605) [IBM XLC++] errors compiling dynatype.cpp

Posted by "Martin Sebor (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/STDCXX-605?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Martin Sebor updated STDCXX-605:
--------------------------------

          Environment: XLC++ 6.0 through 9.0/AIX 5.3  (was: XLC++ 9.0/AIX 5.3)
    Affects Version/s:     (was: trunk)
                       4.2
              Summary: [IBM XLC++] errors compiling dynatype.cpp  (was: [IBM XLC++ 9.0] errors compiling dynatype.cpp)

The same problem occurs with all previous versions of XLC++ and VisualAge C++ all the way through 6.0. The error is the same in all cases.


> [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
>         Environment: XLC++ 6.0 through 9.0/AIX 5.3
>            Reporter: Martin Sebor
>             Fix For: 4.2.1
>
>
> 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.


[jira] Updated: (STDCXX-605) [IBM XLC++] errors compiling dynatype.cpp

Posted by "Travis Vitek (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/STDCXX-605?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Travis Vitek updated STDCXX-605:
--------------------------------

    Attachment:     (was: stdcxx-605.patch)

> [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
>
>
> 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.


[jira] Updated: (STDCXX-605) [IBM XLC++] errors compiling dynatype.cpp

Posted by "Travis Vitek (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/STDCXX-605?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Travis Vitek updated STDCXX-605:
--------------------------------

    Attachment:     (was: stdcxx-605.patch)

> [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
>
>
> 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.


[jira] Updated: (STDCXX-605) [IBM XLC++] errors compiling dynatype.cpp

Posted by "Travis Vitek (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/STDCXX-605?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Travis Vitek updated STDCXX-605:
--------------------------------

    Attachment:     (was: stdcxx-605.patch)

> [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
>
>
> 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.


[jira] Issue Comment Edited: (STDCXX-605) [IBM XLC++] errors compiling dynatype.cpp

Posted by "Travis Vitek (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/STDCXX-605?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12553208 ] 

vitek edited comment on STDCXX-605 at 12/18/07 6:49 PM:
---------------------------------------------------------------

In the failure you mention, the conversion we want is to `const int&'. The conversion operator that gets invoked is the non-const `operator T&'  with 'T' being 'const int'. That conversion operator calls the non-const retrieve(), which keeps the const and looks in the static dynatype::map<const int> for a value. We should be looking in dynatype::map<int>, but the const is not being stripped.

Consider the following...

struct S
{
private:
    template <class T> int g (T*) { return 0; }
    template <class T> int g (const T*) const { return 1; }
public:
    template <class T> int f () { return g ((T*)0); }
};

int main ()
{
    const int a = S().f<int>();
    const int b = S().f<const int>();

    return (a << 1) | b;
}

I believe that the expected result is 0. When compiling the S().f<const int>(), I see a few candidate functions for overload resolution. Given that the overload resolution system treats member functions as if they were free functions with a correctly cv-qualified implicit object parameter, the candidates would seem to be

    int S_g(S&, int*);
    int S_g(S&, const int*);

from the first template, and 

    int S_g(const S&, const int*);

from the second. The actual type of the call is

    ??? S_g(S&, const int*);

So the best match is easily selected, and the result is a call to the non-const 'g' template, which leaves the const on the template type T instead of stripping it like we want.

Continuing with the example, I see a few options. We could make both 'g' overloads share the same constness. If we make them have the same constness, then the overload resolution chooses the best match based on the explicit parameter type, and then discards const as we want. The disadvantage of this is that we would either have two const overloads of 'g' [which you didn't appear to like], or we can have two non-const overloads and cast away const when calling from a const member function. A third option would be to make both 'g' overloads into non-member functions that takes const S* [essentially the same as making both members const], but that would require some code rearranging.

Personally I thought that the two const retrieve() overloads was the simplest and cleanest solution [stdcxx-605-v2.patch]. The most recent patch involves changing fewer lines of code in the example, but it leaves a nasty static/const cast [stdcxx-605-v1.patch].

      was (Author: vitek):
    In the failure you mention, the conversion we want is to `const int&'. The conversion operator that gets invoked is the non-const `operator T&'  with 'T' being 'const int'. That conversion operator calls the non-const retrieve(), which keeps the const and looks in the static dynatype::map<const int> for a value. We should be looking in dynatype::map<int>, but the const is not being stripped.

Consider the following...

struct S
{
private:
    template <class T> int g (T*) { return 0; }
    template <class T> int g (const T*) const { return 1; }
public:
    template <class T> int f () { return g ((T*)0); }
};

int main ()
{
    const int a = S().f<int>();
    const int b = S().f<const int>();

    return (a << 1) | b;
}

I believe that the expected result is 0. When compiling the S().f<const int>(), I see a few candidate functions for overload resolution. Given that the overload resolution system treats member functions as if they were free functions with a correctly cv-qualified implicit object parameter, the candidates would seem to be

    int S_g(S&, int*);
    int S_g(S&, const int*);

from the first template, and 

    int S_g(const S&, int*);
    int S_g(const S&, const int*);

from the second. The actual type of the call is

    ??? S_g(S&, const int*);

So the best match is easily selected, and the result is a call to the non-const 'g' template, which leaves the const on the template type T instead of stripping it like we want.

Continuing with the example, I see a few options. We could make both 'g' overloads share the same constness. If we make them have the same constness, then the overload resolution chooses the best match based on the explicit parameter type, and then discards const as we want. The disadvantage of this is that we would either have two const overloads of 'g' [which you didn't appear to like], or we can have two non-const overloads and cast away const when calling from a const member function. A third option would be to make both 'g' overloads into non-member functions that takes const S* [essentially the same as making both members const], but that would require some code rearranging.

Personally I thought that the two const retrieve() overloads was the simplest and cleanest solution [stdcxx-605-v2.patch]. The most recent patch involves changing fewer lines of code in the example, but it leaves a nasty static/const cast [stdcxx-605-v1.patch].
  
> [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-out.patch, stdcxx-605-v1.patch, stdcxx-605-v2.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.


[jira] Commented: (STDCXX-605) [IBM XLC++] errors compiling dynatype.cpp

Posted by "Martin Sebor (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/STDCXX-605?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12551167 ] 

Martin Sebor commented on STDCXX-605:
-------------------------------------

Looks like you've been able to come up with a clean solution after all -- excellent!

I do have one question about the patch to make sure I understand how it works: do both overloads of retrieve() need to be const? It seems that the one returning (non-const) T& should be non-const, no? (And shouldn't the call to the const overload cast the argument to const T* instead of plain T*?)

Also, there are a few gratuitous whitespace edits in the patch (unnecessarily added newlines) that should normally be avoided, and a few formatting issues (missing spaces before open parens).

> [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.


[jira] Closed: (STDCXX-605) [IBM XLC++] errors compiling dynatype.cpp

Posted by "Travis Vitek (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/STDCXX-605?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Travis Vitek closed STDCXX-605.
-------------------------------

    Resolution: Fixed

Verified in nightly testing.

> [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-out.patch, stdcxx-605-v1.patch, stdcxx-605-v2.patch, stdcxx-605-v3.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.


[jira] Updated: (STDCXX-605) [IBM XLC++] errors compiling dynatype.cpp

Posted by "Martin Sebor (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/STDCXX-605?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Martin Sebor updated STDCXX-605:
--------------------------------

    Attachment: stdcxx-605-v3.patch

What do you think about the modification in the attached patch?

> [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-out.patch, stdcxx-605-v1.patch, stdcxx-605-v2.patch, stdcxx-605-v3.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.