[Boost-bugs] [Boost C++ Libraries] #6811: Default argument of type multi_array fails under MSVC 2010 SP1

Subject: [Boost-bugs] [Boost C++ Libraries] #6811: Default argument of type multi_array fails under MSVC 2010 SP1
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-04-20 07:46:30


#6811: Default argument of type multi_array fails under MSVC 2010 SP1
--------------------------------------------+-------------------------------
 Reporter: Bruce Merry <bmerry@…> | Owner: garcia
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: multi_array
  Version: Boost 1.49.0 | Severity: Problem
 Keywords: |
--------------------------------------------+-------------------------------
 When I write a function with the signature

 {{{
 typedef boost::multi_array<int, 3> T;
 void bar(const T &value = T())
 }}}
 and compile it with MSVC 2010 SP1 I get the following error messages
 {{{
 E:\postdoc\boost-bug>cl /EHsc /Ie:/postdoc/tools/boost_1_49_0 mar-bug.cpp
 Microsoft (R) C/C++ Optimizing Compiler Version 16.00.40219.01 for x64
 Copyright (C) Microsoft Corporation. All rights reserved.

 mar-bug.cpp
 e:/postdoc/tools/boost_1_49_0\boost/multi_array/multi_array_ref.hpp(73) :
 error
 C3855: 'boost::const_multi_array_ref': template parameter 'NumDims' is
 incompati
 ble with the declaration
 e:/postdoc/tools/boost_1_49_0\boost/multi_array/multi_array_ref.hpp(417)
  : see reference to class template instantiation
 'boost::const_multi_array_ref<T
 ,NumDims,TPtr>' being compiled
         with
         [
             T=int,
             NumDims=0x03,
             TPtr=int *
         ]
         e:/postdoc/tools/boost_1_49_0\boost/multi_array.hpp(113) : see
 reference
  to class template instantiation 'boost::multi_array_ref<T,NumDims>' being
 compi
 led
         with
         [
             T=int,
             NumDims=0x03
         ]
         mar-bug.cpp(5) : see reference to class template instantiation
 'boost::m
 ulti_array<T,NumDims>' being compiled
         with
         [
             T=int,
             NumDims=0x03
         ]
 }}}

 The offending piece of code appears to be in
 `boost/multi_array/multi_array_ref.hpp`:

 {{{
  #ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
    // make const_multi_array_ref a friend of itself
    template <typename,std::size_t,typename>
    friend class const_multi_array_ref;
 #endif
 }}}

 If I give the template arguments names then the compiler is happy (I'll
 attach a patch).

 I have no idea what is special about using the type as a default argument
 - I tried to reproduce it using simpler steps (copy constructor, default
 constructor, assigning a temporary to a const ref inside a function) with
 no luck.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/6811>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:09 UTC