Opened 11 years ago

#6811 new Bugs

Default argument of type multi_array fails under MSVC 2010 SP1

Reported by: Bruce Merry <bmerry@…> Owned by: Ronald Garcia
Milestone: To Be Determined Component: multi_array
Version: Boost 1.49.0 Severity: Problem
Keywords: Cc:

Description

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.

Attachments (2)

mar-bug.cpp (132 bytes ) - added by Bruce Merry <bmerry@…> 11 years ago.
Test case illustrating the bug
boost_1_49_0-multi_array_ref.patch (419 bytes ) - added by Bruce Merry <bmerry@…> 11 years ago.
Patch that fixes the problem under MSVC

Download all attachments as: .zip

Change History (2)

by Bruce Merry <bmerry@…>, 11 years ago

Attachment: mar-bug.cpp added

Test case illustrating the bug

by Bruce Merry <bmerry@…>, 11 years ago

Patch that fixes the problem under MSVC

Note: See TracTickets for help on using tickets.