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

Invalid code for properties with const reference types #1323

Closed
tritao opened this issue Apr 4, 2020 · 0 comments
Closed

Invalid code for properties with const reference types #1323

tritao opened this issue Apr 4, 2020 · 0 comments
Assignees
Labels

Comments

@tritao
Copy link
Collaborator

tritao commented Apr 4, 2020

Brief Description

Invalid code is generated for properties with const reference types in C# generator.

And maybe C++/CLI as well, did not check.

Used headers
diff --git a/tests/Common/Common.cpp b/tests/Common/Common.cpp
index 2cbdddc3..84089107 100644
--- a/tests/Common/Common.cpp
+++ b/tests/Common/Common.cpp
@@ -538,13 +538,13 @@ SomeNamespace::AbstractClass::~AbstractClass()
 {
 }
 
-TestProperties::TestProperties() : Field(0), _refToPrimitiveInSetter(0),
+TestProperties::TestProperties() : Field(0), ConstRefField(Field), _refToPrimitiveInSetter(0),
     _getterAndSetterWithTheSameName(0), _setterReturnsBoolean(0), _virtualSetterReturnsBoolean(0)
 {
 }
 
 TestProperties::TestProperties(const TestProperties& other) : Field(other.Field),
-    FieldValue(other.FieldValue),
+    ConstRefField(other.ConstRefField), FieldValue(other.FieldValue),
     _refToPrimitiveInSetter(other._refToPrimitiveInSetter),
     _getterAndSetterWithTheSameName(other._getterAndSetterWithTheSameName),
     _setterReturnsBoolean(other._setterReturnsBoolean),
diff --git a/tests/Common/Common.h b/tests/Common/Common.h
index 01d6b994..5e919660 100644
--- a/tests/Common/Common.h
+++ b/tests/Common/Common.h
@@ -592,6 +592,7 @@ public:
     TestProperties();
     TestProperties(const TestProperties& other);
     int Field;
+    const int& ConstRefField;
 
     int getFieldValue();
     void setFieldValue(int Value);
@@ -1594,4 +1595,4 @@ class TemplateClass : TemplateClassBase<A,B> {
     using typename TemplateClassBase<A,B>::XType;
     using Func = std::function<B(XType)>;
     explicit TemplateClass(Func function) {}
-};
\ No newline at end of file
+};
Stack trace or incompilable generated code
        public int ConstRefField
        {
            get
            {
                return *((global::CommonTest.TestProperties.__Internal*) __Instance)->ConstRefField;
            }

            set
            {
                ((global::CommonTest.TestProperties.__Internal*)__Instance)->ConstRefField = &value;
            }
        }
@tritao tritao added the bug label Apr 4, 2020
ddobrev added a commit that referenced this issue May 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants