Anyone have access to Sun Studio 12 compiler?

I have a bug report on that compiler (Sparc, Solaris 9) that I don't have any way to reproduce. Thanks! -- Marshall There are only two hard problems in computer science: cache invalidation, naming things, and off-by-one errors.

On Wed, Oct 20, 2010 at 07:52:40AM -0700, Marshall Clow wrote:
I have a bug report on that compiler (Sparc, Solaris 9) that I don't have any way to reproduce.
It is reproducable on one of the machines [1] I have access to at my university (Solaris 10, sparc, SunStudio 12) with the command line [2] and test program [3] shown below, producing the below errors [4], where :351 and :358 are the definitions of the free c_array functions of Boost.Array. [1] SunOS vega 5.10 Generic_142909-17 sun4u sparc SUNW,Sun-Fire-V240 Solaris [2] "CC" -library=stlport4 -xldscope=hidden -xO4 -mt -erroff=%none -KPIC -DBOOST_ALL_NO_LIB=1 -DBOOST_MATH_TR1_DYN_LINK=1 -DNDEBUG -I"." -I"libs/math/src/tr1" -o 4757 4757.cc [3] // 4757.cc // ----8<---- #include <boost/array.hpp> int main() {} // ----8<---- [4] "./boost/array.hpp", line 351: Error: An integer constant expression is required within the array subscript operator. "./boost/array.hpp", line 358: Error: An integer constant expression is required within the array subscript operator. 2 Error(s) detected. -- Lars Viklund | zao@acc.umu.se

On Oct 20, 2010, at 9:49 AM, Lars Viklund wrote:
On Wed, Oct 20, 2010 at 07:52:40AM -0700, Marshall Clow wrote:
I have a bug report on that compiler (Sparc, Solaris 9) that I don't have any way to reproduce.
It is reproducable on one of the machines [1] I have access to at my university (Solaris 10, sparc, SunStudio 12) with the command line [2] and test program [3] shown below, producing the below errors [4], where :351 and :358 are the definitions of the free c_array functions of Boost.Array.
[1] SunOS vega 5.10 Generic_142909-17 sun4u sparc SUNW,Sun-Fire-V240 Solaris
[2] "CC" -library=stlport4 -xldscope=hidden -xO4 -mt -erroff=%none -KPIC -DBOOST_ALL_NO_LIB=1 -DBOOST_MATH_TR1_DYN_LINK=1 -DNDEBUG -I"." -I"libs/math/src/tr1" -o 4757 4757.cc
[3] // 4757.cc // ----8<---- #include <boost/array.hpp> int main() {} // ----8<----
[4] "./boost/array.hpp", line 351: Error: An integer constant expression is required within the array subscript operator. "./boost/array.hpp", line 358: Error: An integer constant expression is required within the array subscript operator.
Yeah - it's complaining about a method in boost::array: // Specific for boost::array: simply returns its elems data member. template <typename T, std::size_t N> T(&get_c_array(boost::array<T,N>& arg))[N] { return arg.elems; } I don't see any subscript operators there at all. ;-) I suspect that this is a limitation of the compiler. Here's a standalone test case:
#include <boost/array.hpp>
int main(int argc, char *argv[]) { boost::array<int,5> arr; return 0; }
-- Marshall

At Wed, 20 Oct 2010 12:08:28 -0700, Marshall Clow wrote:
Yeah - it's complaining about a method in boost::array:
// Specific for boost::array: simply returns its elems data member. template <typename T, std::size_t N> T(&get_c_array(boost::array<T,N>& arg))[N] { return arg.elems; }
I don't see any subscript operators there at all. ;-) I suspect that this is a limitation of the compiler.
My guess is it can't parse the function-returning-reference-to-array syntax. You can try this instead: namespace detail { template <typename T, std::size_t N> struct c_array { typedef T[N] type; }; } // Specific for boost::array: simply returns its elems data member. template <typename T, std::size_t N> typename detail::c_array<T,N>::type& get_c_array(boost::array<T,N>& arg) { return arg.elems; } HTH, -- Dave Abrahams BoostPro Computing http://www.boostpro.com

On Thu, Oct 21, 2010 at 07:49:29AM -0400, David Abrahams wrote:
At Wed, 20 Oct 2010 12:08:28 -0700, Marshall Clow wrote:
Yeah - it's complaining about a method in boost::array:
// Specific for boost::array: simply returns its elems data member. template <typename T, std::size_t N> T(&get_c_array(boost::array<T,N>& arg))[N] { return arg.elems; }
My guess is it can't parse the function-returning-reference-to-array syntax. You can try this instead:
namespace detail { template <typename T, std::size_t N> struct c_array { typedef T[N] type; }; }
// Specific for boost::array: simply returns its elems data member. template <typename T, std::size_t N> typename detail::c_array<T,N>::type& get_c_array(boost::array<T,N>& arg) { return arg.elems; }
That code, together with the corresponding const variant [1] of the second function, makes building --with-math get past the previous trouble spots without problems. As this machine is horribly slow, I haven't finished building yet, but it seems to fix the problem the reporter reported in his report. [1] ---8<--- // Specific for boost::array: simply returns its elems data member. template <typename T, std::size_t N> const typename detail::c_array<T,N>::type& get_c_array(const boost::array<T,N>& arg) { return arg.elems; } ---8<--- -- Lars Viklund | zao@acc.umu.se

On Oct 21, 2010, at 9:12 AM, Lars Viklund wrote:
On Thu, Oct 21, 2010 at 07:49:29AM -0400, David Abrahams wrote:
At Wed, 20 Oct 2010 12:08:28 -0700, Marshall Clow wrote:
Yeah - it's complaining about a method in boost::array:
// Specific for boost::array: simply returns its elems data member. template <typename T, std::size_t N> T(&get_c_array(boost::array<T,N>& arg))[N] { return arg.elems; }
My guess is it can't parse the function-returning-reference-to-array syntax. You can try this instead:
namespace detail { template <typename T, std::size_t N> struct c_array { typedef T[N] type; }; }
// Specific for boost::array: simply returns its elems data member. template <typename T, std::size_t N> typename detail::c_array<T,N>::type& get_c_array(boost::array<T,N>& arg) { return arg.elems; }
That code, together with the corresponding const variant [1] of the second function, makes building --with-math get past the previous trouble spots without problems.
Thanks for the suggestion, Dave. Sadly, on my machine, both gcc 4.2.1 and clang 2.8 reject this code with: /Marshall/Sources/boost/trunk/boost/array.hpp:367:21: error: expected member name or ';' after declaration specifiers typedef T[N] type; ~~~~~~~~~^ 1 error generated. --- or --- ../../../boost/array.hpp:367: error: expected unqualified-id before '[' token This, however, seems to work: namespace detail { template <typename T, std::size_t N> struct c_array { typedef T type[N]; }; } I've checked this in as revision #66154 and will watch the tests cycle. -- Marshall
participants (3)
-
David Abrahams
-
Lars Viklund
-
Marshall Clow