C++/CLI indexed property serious bug!

I

Ioannis Vranos

Fellows there is probably a serious implementation bug of C++/CLI
indexed property in VC++ 2005, it looks like it is implemented the
opposite way than the C++/CLI draft says!


At first the latest C++/CLI draft is 1.7 and you can download it from here:

http://www.plumhall.com/C++-CLI draft 1.7.pdf


But the draft that MS currently provides for downloading also says the same.


An implementation example of default indexed property is provided on
page 22 of the C++/CLI draft.


Based on the draft the following should compile:

ref class SomeClass
{
public:
property unsigned default[int]
{
unsigned get(int index) { return 1; }
void set(unsigned value, int index) {}
}
};



int main()
{
SomeClass obj;
}


However it does not:

C:\c>cl /clr:safe temp.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 14.00.40904
for Microsoft (R) .NET Framework version 2.00.40607.16
Copyright (C) Microsoft Corporation. All rights reserved.

temp.cpp
temp.cpp(7) : error C3902: 'set': type of last parameter must be
'unsigned int'
temp.cpp(7) : error C2192: parameter '1' declaration different

C:\c>



The compiler wants the arguments the other way around:

void set(int index, unsigned value) {}



Unless I am mistaken there, is a serious implementation error of the
indexed property concept.


I had initially reported the issue as a bug under the subject

"C++/CLI indexed property implementation bug".


Please check it, and tell the appropriate channels to look it closer, or
tell me what I have to do to make it reconsidered again!
 
T

Tomas Restrepo \(MVP\)

Ioannis,
Fellows there is probably a serious implementation bug of C++/CLI
indexed property in VC++ 2005, it looks like it is implemented the
opposite way than the C++/CLI draft says!

Sounds to me like it's the spec that is wrong, not the compiler...

Just file it as a spec bug using the MSDN product feedback page.
 
I

Ioannis Vranos

Tomas said:
Sounds to me like it's the spec that is wrong, not the compiler...

Just file it as a spec bug using the MSDN product feedback page.


Do you mean that it is a bug of the standard? :))
 
C

Carl Daniel [VC++ MVP]

Ioannis said:
Yep.

Also there is no spec option in the bug category in the feedback page.

Then file it as a compiler bug but indicate in the description that you
don't know if the compiler or the spec is wrong, just that they disagree.

-cd
 
I

Ioannis Vranos

Carl said:
Then file it as a compiler bug but indicate in the description that you
don't know if the compiler or the spec is wrong, just that they disagree.


But how can it be the standard to be in error and an implementation to
be the right?

This is the first time I encounter such an explanation. :)
 
C

Carl Daniel [VC++ MVP]

Ioannis said:
But how can it be the standard to be in error and an implementation to
be the right?

This is the first time I encounter such an explanation. :)

There is no standard - just a draft standard, that's how. It's just as much
a work in progress as the compiler is. The people defining the compiler
are, to a large extent, the same people who are defining the standard, so
any inconsistency like this could potentially be resolved either way.

-cd
 
I

Ioannis Vranos

Carl said:
Then file it as a compiler bug but indicate in the description that you
don't know if the compiler or the spec is wrong, just that they disagree.


I have reposted it under the subject:

"C++/CLI draft standard and VC++ 2005 Express Beta 1 property
implementation *inconsistency*".


The original message was:

"C++/CLI indexed property implementation bug".



I hope it will be checked thoroughly.
 
P

Puchi

I think you are confusing the indexed property syntax. See code below your
comments.

Ioannis Vranos said:
Fellows there is probably a serious implementation bug of C++/CLI
indexed property in VC++ 2005, it looks like it is implemented the
opposite way than the C++/CLI draft says!


At first the latest C++/CLI draft is 1.7 and you can download it from here:

http://www.plumhall.com/C++-CLI draft 1.7.pdf


But the draft that MS currently provides for downloading also says the same.


An implementation example of default indexed property is provided on
page 22 of the C++/CLI draft.


Based on the draft the following should compile:

ref class SomeClass
{
public:
property unsigned default[int]
{
unsigned get(int index) { return 1; }
void set(unsigned value, int index) {}
}
};



int main()
{
SomeClass obj;
}


However it does not:

C:\c>cl /clr:safe temp.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 14.00.40904
for Microsoft (R) .NET Framework version 2.00.40607.16
Copyright (C) Microsoft Corporation. All rights reserved.

temp.cpp
temp.cpp(7) : error C3902: 'set': type of last parameter must be
'unsigned int'
temp.cpp(7) : error C2192: parameter '1' declaration different

C:\c>



The compiler wants the arguments the other way around:

void set(int index, unsigned value) {}



Unless I am mistaken there, is a serious implementation error of the
indexed property concept.


I had initially reported the issue as a bug under the subject

"C++/CLI indexed property implementation bug".


Please check it, and tell the appropriate channels to look it closer, or
tell me what I have to do to make it reconsidered again!

// The code should be:

ref class SomeClass
{
public:
property unsigned default[int]
{
unsigned get(int index) { return 1.0; }
void set(int index, unsigned value) {}
}
};



int main()
{
SomeClass obj;
}


The setter should have the last parameter as unsigned and not the first.
Hope it helps.
Thanks,
Kapil
 
P

Puchi

You are right. We need to update the C++/CLI docs.
I spoke to the person responsible and will be fixed in the future versions.
Thanks,
Kapil
 

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

Top