LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 25636 - MSVC __declspec(property) - Indexed accessor property not supported correctly (clang 4.2.1)
Summary: MSVC __declspec(property) - Indexed accessor property not supported correctly...
Status: RESOLVED FIXED
Alias: None
Product: clang
Classification: Unclassified
Component: C++ (show other bugs)
Version: trunk
Hardware: PC Windows NT
: P normal
Assignee: Alexey Bataev
URL: https://msdn.microsoft.com/en-us/libr...
Keywords: miscompilation
: 25635 (view as bug list)
Depends on:
Blocks:
 
Reported: 2015-11-25 09:46 PST by David Simmons
Modified: 2015-12-09 22:38 PST (History)
4 users (show)

See Also:
Fixed By Commit(s):


Attachments
Repro - somehow it was dropped from original submission (1.76 KB, application/octet-stream)
2015-11-25 09:50 PST, David Simmons
Details

Note You need to log in before you can comment on or make changes to this bug.
Description David Simmons 2015-11-25 09:46:01 PST
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 a*b; }
        ^
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 a*b; }
        ^
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.
Comment 1 David Simmons 2015-11-25 09:46:50 PST
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);
Comment 2 David Simmons 2015-11-25 09:50:40 PST
Created attachment 15354 [details]
Repro - somehow it was dropped from original submission

Repro for bug 25636: Somehow it was dropped from original submission
Comment 3 David Simmons 2015-11-25 09:55:03 PST
This is the incompatibility:
  __declspec(property(get = get_index_y, put = put_index_y)) 
   /* ==> */ int Y[];
Comment 4 David Simmons 2015-11-25 12:38:26 PST
*** Bug 25635 has been marked as a duplicate of this bug. ***
Comment 5 Reid Kleckner 2015-11-30 18:19:31 PST
Thank for the report, be aware this functionality is pretty new.
Comment 6 Alexey Bataev 2015-12-01 05:23:28 PST
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?
Comment 7 David Simmons 2015-12-04 02:37:41 PST
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.
Comment 8 Alexey Bataev 2015-12-04 02:47:41 PST
(In reply to comment #7)
> 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
Comment 9 Alexey Bataev 2015-12-09 22:38:56 PST
Committed revision 255218.