help with gcc 3.1 error message

K

ken

I cannot see how I am getting this error message:

TreeAddress aResult( memory::pointer(aBaseAddress) );

if (TreeFragment * pFragment = TreeAccessor::access(aResult,_anUpdater))


/data2/office/configmgr/source/tree/builddata.cxx: In member function
`configmgr ::data::TreeAddress configmgr::data::TreeNodeBuilder::
allocTreeFragment(configmg r::memory::UpdateAccessor&)':
/data2/office/configmgr/source/tree/builddata.cxx:658: error: no matching
function for
call to `configmgr::data::TreeAccessor::access(configmgr::data::TreeAddress (&)
(configmgr::memory::pointer), configmgr::memory::UpdateAccessor&)'
.../inc/treeaccessor.hxx:139: error: candidates are
: static configmgr::sharable:: TreeFragment*
configmgr::data::TreeAccessor::
access(const configmgr::data::TreeA ddress&,
configmgr::memory::UpdateAccessor&)
.../inc/treeaccessor.hxx:141: error: static const configmgr::shar
able::TreeFragment*
configmgr::data::TreeAccessor::access(const configmgr::data:
:TreeAddress&,
const configmgr::memory::Accessor&)
 
R

Rob Williscroft

ken wrote in
I cannot see how I am getting this error message:

TreeAddress aResult( memory::pointer(aBaseAddress) );

The above is a function declaration ie:

TreeAddress aResult( memory::pointer aBaseAddress );

change it to:

TreeAddress aResult = memory::pointer(aBaseAddress);

or maybe:

TreeAddress aResult( ( memory::pointer(aBaseAddress) ) );

if (TreeFragment * pFragment =
TreeAccessor::access(aResult,_anUpdater))


/data2/office/configmgr/source/tree/builddata.cxx: In member function
`configmgr ::data::TreeAddress configmgr::data::TreeNodeBuilder::
allocTreeFragment(configmg r::memory::UpdateAccessor&)':
/data2/office/configmgr/source/tree/builddata.cxx:658: error: no
matching function for
call to

This is the bit you needed to read carefully:
`configmgr::data::TreeAccessor::access(configmgr::data::TreeAddress
(&) (configmgr::memory::pointer), configmgr::memory::UpdateAccessor&)'

Note the type of the first argument.
../inc/treeaccessor.hxx:139: error: candidates are
: static configmgr::sharable:: TreeFragment*
configmgr::data::TreeAccessor::
access(const configmgr::data::TreeA ddress&,
configmgr::memory::UpdateAccessor&)
../inc/treeaccessor.hxx:141: error: static const configmgr::shar
able::TreeFragment*
configmgr::data::TreeAccessor::access(const configmgr::data:
:TreeAddress&,
const configmgr::memory::Accessor&)

HTH

Rob.
 
M

Michael Kochetkov

Rob Williscroft said:
ken wrote in

The above is a function declaration ie:

TreeAddress aResult( memory::pointer aBaseAddress );

change it to:

TreeAddress aResult = memory::pointer(aBaseAddress);

or maybe:

TreeAddress aResult( ( memory::pointer(aBaseAddress) ) );
No, it will not help. You might with to consider the proper static_cast
instead.
 
K

ken

No, it will not help. You might with to consider the proper static_cast
instead.

Static cast was the original code. It compiled fine until 3.3.1

TreeAddress aResult( static_cast<memory::pointer>(aBaseAddress) );

Isn't memory::pointer(aBaseAddress) instantiating a temporary of type
memory::pointer, not declaring a variable ABaseAddress. The brackets
are calling the constructor.

I now understand how to work around this, I just don't understand what I did
wrong.
 
J

John Harrison

ken said:
Static cast was the original code. It compiled fine until 3.3.1

TreeAddress aResult( static_cast<memory::pointer>(aBaseAddress) );

Isn't memory::pointer(aBaseAddress) instantiating a temporary of type
memory::pointer, not declaring a variable ABaseAddress. The brackets
are calling the constructor.

I now understand how to work around this, I just don't understand what I did
wrong.

No, memory::pointer(aBaseAddress) is a parameter type, followed by a
parameter name. The brackets are ignored. I.e.

TreeAddress aResult( memory::pointer(aBaseAddress) );

is exactly the same as

TreeAddress aResult( memory::pointer aBaseAddress );

which is a function prototype.

There is a rule in C++, if something could be an expression or a
declaration, its treated as a declaration. See the recent thread 'Temporary
creation vs. variable declaration' for other examples.

john
 
M

Michael Kochetkov

Rob Williscroft said:
Michael Kochetkov wrote in

Maybe, but if so, you and the OP have non-comforming compilers.
Right you are. I have overlooked the opening parenthesis place (I have
considered TreeAddress (aResult( memory::pointer(aBaseAddress) ) ); ).
Sorry.
 
K

ken

There is a rule in C++, if something could be an expression or a
declaration, its treated as a declaration. See the recent thread 'Temporary
creation vs. variable declaration' for other examples.

The penny drops, thanks for your help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,126
Messages
2,570,753
Members
47,313
Latest member
SamualGriz

Latest Threads

Top