<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/90743>90743</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
__declspec properties outside of class members do not work as expected
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
kodenamekrak
</td>
</tr>
</table>
<pre>
As shown in the example below, the properties return unexpected results when used outside of class members.
Although, according to [Microsoft's specification](https://learn.microsoft.com/en-us/cpp/cpp/property-cpp?view=msvc-170), they shouldnt be allowed outside of members and should cause [error C3065](https://learn.microsoft.com/en-us/cpp/error-messages/compiler-errors-2/compiler-error-c3065?view=msvc-170)
https://godbolt.org/z/jqe59vW85
```cpp
#include <cstdio>
struct Color {
float r, g, b, a;
};
struct Test {
Color get_value() {
return Color{1.0f, 0.5f, 0.5f, 1.0f};
}
__declspec(property(get=get_value)) Color value;
};
Color get_value() {
return Color{1.0f, 0.5f, 0.5f, 1.0f};
}
__declspec(property(get=get_value)) Color value;
int main() {
Test t;
auto color2 = t.value;
printf("%f, %f, %f, %f\n", color2.r, color2.g, color2.b, color2.a);
// returns empty ?
auto color3 = value;
printf("%f, %f, %f, %f\n", color3.r, color3.g, color3.b, color3.a);
auto color4 = get_value();
printf("%f, %f, %f, %f\n", color4.r, color4.g, color4.b, color4.a);
return 0;
}
```
```
1.000000, 0.500000, 0.500000, 1.000000
0.000000, 0.000000, 0.000000, 0.000000
1.000000, 0.500000, 0.500000, 1.000000
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyslUFv8ygTgH8NuYxiEbDr-OBDm3y5fbeV9lhhPHZ4i8ELOHm7v34FcVOnTbWrqlaEh2FmeAZPGOG96g1iTYonUuxXYgpH6-oX26IRA7448bJqbPtaP3rwR3s2oAyEIwL-FsOoERrU9kzYLilHZ0d0QaEHh2FyBiaDv0eUAVtw6CcdPJyPaGDy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