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