Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSVC __declspec(property) - Indexed accessor property not supported correctly (clang 4.2.1) #26010

Closed
llvmbot opened this issue Nov 25, 2015 · 10 comments
Assignees
Labels
bugzilla Issues migrated from bugzilla c++ miscompilation

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Nov 25, 2015

Bugzilla Link 25636
Resolution FIXED
Resolved on Dec 09, 2015 22:38
Version trunk
OS Windows NT
Reporter LLVM Bugzilla Contributor
CC @alexey-bataev,@DougGregor,@rnk

Extended Description

Indexed accessor property not supported correctly
in clang "4.2.1 Compatible Clang 3.8.0 (trunk)"

// See: https://msdn.microsoft.com/en-us/library/yhfk0thd.aspx
// __declspec(property(get=GetX, put=PutX)) int x[];
// The above statement indicates that x[] can be used with one or more
// array indices. In this case, i=p->x[a][b] will be turned into
// i=p->GetX(a, b), and p->x[a][b] = i will be turned into p->PutX(a, b, i);

Output from MSVC is as follows:
1>------ Rebuild All started: Project: LlvmMsVcProperties, Configuration: Debug Win32 ------
1> LlvmMsVcProperties.cpp
1> LlvmMsVcProperties.vcxproj -> LlvmMsVcProperties.exe
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
< PropertyTest::PropertyTest(10)

x=10
this->Y[1] : 1
this->Y[2][3] : 6
< set_a_y as Y[4]=5 : 20
this->Y[4]=5 : 20
< set_a_b_y as Y[6][7]=8: 336
this->Y[6][7]=8 : 336
=================================================
=================================================
clang/clang-cl version: ...
#define VERSION "4.2.1 Compatible Clang 3.8.0 (trunk)"
-fms-compatibility

REPORTS:
lvmMsVcProperties.cpp(32,56): error : no matching member function for call to 'get_index_y'
printf(">this->Y[1] : %d\n", this->Y[1]);
~~~~~~^
LlvmMsVcProperties.cpp(13,9) : note: candidate function not viable: requires single argument 'a', but no arguments were provided
int get_index_y(int a) { return a; }
^
LlvmMsVcProperties.cpp(14,9) : note: candidate function not viable: requires 2 arguments, but 0 were provided
int get_index_y(int a, int b) { return ab; }
^
lvmMsVcProperties.cpp(33,56): error : no matching member function for call to 'get_index_y'
printf(">this->Y[2][3] : %d\n", this->Y[2][3]);
~~~~~~^
LlvmMsVcProperties.cpp(13,9) : note: candidate function not viable: requires single argument 'a', but no arguments were provided
int get_index_y(int a) { return a; }
^
LlvmMsVcProperties.cpp(14,9) : note: candidate function not viable: requires 2 arguments, but 0 were provided
int get_index_y(int a, int b) { return a
b; }
^
lvmMsVcProperties.cpp(34,57): error : no matching member function for call to 'get_index_y'
printf(">this->Y[4]=5 : %d\n", (this->Y[4]=5));
~~~~~~^
LlvmMsVcProperties.cpp(13,9) : note: candidate function not viable: requires single argument 'a', but no arguments were provided
int get_index_y(int a) { return a; }
^
LlvmMsVcProperties.cpp(14,9) : note: candidate function not viable: requires 2 arguments, but 0 were provided
int get_index_y(int a, int b) { return ab; }
^
lvmMsVcProperties.cpp(35,57): error : no matching member function for call to 'get_index_y'
printf(">this->Y[6][7]=8 : %d\n", (this->Y[6][7]=8));
~~~~~~^
LlvmMsVcProperties.cpp(13,9) : note: candidate function not viable: requires single argument 'a', but no arguments were provided
int get_index_y(int a) { return a; }
^
LlvmMsVcProperties.cpp(14,9) : note: candidate function not viable: requires 2 arguments, but 0 were provided
int get_index_y(int a, int b) { return a
b; }
^
4 errors generated.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Nov 25, 2015

assigned to @alexey-bataev

@llvmbot
Copy link
Collaborator Author

llvmbot commented Nov 25, 2015

in clang "4.2.1 Compatible Clang 3.8.0 (trunk)"

// See: https://msdn.microsoft.com/en-us/library/yhfk0thd.aspx
// __declspec(property(get=GetX, put=PutX)) int x[];
// The above statement indicates that x[] can be used with one or more
// array indices. In this case, i=p->x[a][b] will be turned into
// i=p->GetX(a, b), and p->x[a][b] = i will be turned into p->PutX(a, b, i);

@llvmbot
Copy link
Collaborator Author

llvmbot commented Nov 25, 2015

Repro - somehow it was dropped from original submission
Repro for bug 25636: Somehow it was dropped from original submission

@llvmbot
Copy link
Collaborator Author

llvmbot commented Nov 25, 2015

This is the incompatibility:
__declspec(property(get = get_index_y, put = put_index_y))
/* ==> */ int Y[];

@llvmbot
Copy link
Collaborator Author

llvmbot commented Nov 25, 2015

*** Bug #26009 has been marked as a duplicate of this bug. ***

@rnk
Copy link
Collaborator

rnk commented Dec 1, 2015

Thank for the report, be aware this functionality is pretty new.

@alexey-bataev
Copy link
Member

  1. Update your compiler to the latest version. I could not reproduce your error messages. Seems to me you're using version before the commit with indexed properties support.
  2. I saw just 2 error messages with the indexed properties
    LlvmMsVcProperties.cpp:35:50: error: cannot pass expression of type 'void' to variadic function
    printf(">this->Y[4]=5 : %d\n", (this->Y[4]=5));
    ^
    LlvmMsVcProperties.cpp:36:50: error: cannot pass expression of type 'void' to variadic function
    printf(">this->Y[6][7]=8 : %d\n", (this->Y[6][7]=8));
    ^
    2 errors generated.

'put' property for assignment does not return value by default. Shall we support this?

@llvmbot
Copy link
Collaborator Author

llvmbot commented Dec 4, 2015

Hi Alexey, it half works now in SVN r254298 (30 November 2015).

With the code sample I originally posted, it now generates the following errors.

3>LlvmMsVcProperties.cpp(34,50): error : cannot pass expression of type 'void' to variadic function; expected type from format string was 'int'
3> printf(">this->Y[4]=5 : %d\n", (this->Y[4]=5));
3> ^~~~~~~~~~~~~~
3>LlvmMsVcProperties.cpp(35,50): error : cannot pass expression of type 'void' to variadic function; expected type from format string was 'int'
3> printf(">this->Y[6][7]=8 : %d\n", (this->Y[6][7]=8));
3> ^~~~~~~~~~~~~~~~~

----------- WHICH CAN BE MORE CLEARLY SEEN BY DOING ----------->
3>LlvmMsVcProperties.cpp(34,14): error : variable has incomplete type 'void'
3> auto r0 = this->Y[4]=5;
3> ^
3>LlvmMsVcProperties.cpp(36,14): error : variable has incomplete type 'void'
3> auto r1 = this->Y[6][7]=8;
3> ^
3> 2 errors generated.

@alexey-bataev
Copy link
Member

Hi Alexey, it half works now in SVN r254298 (30 November 2015).

With the code sample I originally posted, it now generates the following
errors.

3>LlvmMsVcProperties.cpp(34,50): error : cannot pass expression of type
'void' to variadic function; expected type from format string was 'int'
3> printf(">this->Y[4]=5 : %d\n", (this->Y[4]=5));
3> ^~~~~~~~~~~~~~
3>LlvmMsVcProperties.cpp(35,50): error : cannot pass expression of type
'void' to variadic function; expected type from format string was 'int'
3> printf(">this->Y[6][7]=8 : %d\n", (this->Y[6][7]=8));
3> ^~~~~~~~~~~~~~~~~

----------- WHICH CAN BE MORE CLEARLY SEEN BY DOING ----------->
3>LlvmMsVcProperties.cpp(34,14): error : variable has incomplete type 'void'
3> auto r0 = this->Y[4]=5;
3> ^
3>LlvmMsVcProperties.cpp(36,14): error : variable has incomplete type 'void'
3> auto r1 = this->Y[6][7]=8;
3> ^
3> 2 errors generated.

Yes, this is known problem. Patch that fixes this is under review

@alexey-bataev
Copy link
Member

Committed revision 255218.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla c++ miscompilation
Projects
None yet
Development

No branches or pull requests

3 participants