Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/Compiler/C++    [ Add a report in this area ]  
Report #:  101307   Status: Closed
Ternary operators may not work with properties
Project:  C++Builder Build #:  16.0.4316.44803
Version:    16.2 Submitted By:   Luis Branca
Report Type:  Crash / Data loss / Total failure Date Reported:  11/25/2011 3:11:29 AM
Severity:    Serious / Highly visible problem Last Updated: 4/25/2012 6:16:33 PM
Platform:    All versions Internal Tracking #:   288981
Resolution: Fixed (Resolution Comments) Resolved in Build: : Update 4
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: None
Description
Accessing properties through a ternary operator may cause an AV.
Steps to Reproduce:
The following code, causes an Access Violation:

struct {
  __property int Bar = { read = GetBar };
  int GetBar() { return 0; }
  void Foo() {
    int Foo1 = 0;
    const int &Foo2 = (int(Date()) ? Bar : Foo1);
  }
} FooBar;

void __fastcall TForm1::Button1Click(TObject *Sender)
{
  FooBar.Foo();
}

Workarounds
None
Attachment
Win32.zip
Comments

Luis Branca at 4/24/2012 8:28:19 AM -
Seems fixed on XE2 UP4 (16.0.4429.46931).

Tomohiro Takahashi at 4/25/2012 3:49:53 AM -
Thanks for the confirmation. I will check the internal status of this report.

Server Response from: ETNACODE01