View Issue Details

IDProjectCategoryView StatusLast Update
0026773FPCRTLpublic2015-03-14 14:37
ReporterArnaud Bouchez Assigned ToMichael Van Canneyt  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version2.7.1 
Target Version3.0.0Fixed in Version3.0.0 
Summary0026773: TInvokeableVariantType.SetProperty does not allow to change the variant value
DescriptionIn Delphi, custom variant late-binding allows to change the stored TVarData content, even if the parameter is passed as "const" to the overridden SetProperty method.
Setting values via late-binding for custom variant types does not allow to change the stored content under FPC, whereas it is possible in Delphi.

This is some kind of abuse of "const" on the Delphi side, since it should have been defined as "var". But it is needed to change the stored value, via late-binding.

TInvokeableVariantType.SetProperty() and DispInvoke() methods should use a "var" kind of parameter for the source TVarData.

This fix is mandatory for compatibility with Delphi, e.g. for using our Open Source libraries like mORMot, SynMongoDB, SynMustache and our JSON storage library.
Steps To ReproduceUse the supplied SourceBug.dpr file to reproduce the issue.

It works as expected under Delphi, and fails under FPC.
Additional InformationIMHO fix consists in the following changes.

The CONST source parameter should be changed into VAR in the following lines:


1. procedure fpc_dispinvoke_variant(dest : pvardata; VAR source : tvardata; calldesc : pcalldesc;params : pointer);compilerproc;

for the following files:
 - compproc.inc
 - variant.inc
 - jcomproc.inc


2. procedure DispInvoke(Dest: PVarData; VAR Source: TVarData; CallDesc: PCallDesc; Params: Pointer); override;

for the following files:
 - tw17904.pas
 - tw9162.pas
 - variants.pp


3. procedure sysdispinvoke(Dest : PVarData; VAR Source : TVarData;calldesc : pcalldesc;params : Pointer);cdecl;

for the following file:
 - variants.pp


4. dispinvoke: procedure(dest : pvardata; VAR source : tvardata;
        calldesc : pcalldesc;params : pointer);cdecl;

for the following file:
 - varianth.inc


5. function SetProperty(VAR V: TVarData; const Name: string;
      const Value: TVarData): Boolean;

for the following file:
 - variants.pp
Tagsinterface, RTTI
Fixed in Revision28997
FPCOldBugId
FPCTarget
Attached Files

Relationships

related to 0027044 closedSergei Gorelkin Can't take the address of constant expressions (Regression) 
related to 0027668 resolvedMichael Van Canneyt TInvokeableVariantType.setproperty first param is const not var 

Activities

Arnaud Bouchez

2014-09-24 18:03

reporter  

SourceBug.dpr (2,036 bytes)

EgonHugeist/ZeosDevTeam

2014-09-24 21:30

reporter   ~0077611

Well done AB. An issue i was also runnig in.

Michael Van Canneyt

2014-11-05 23:24

administrator   ~0078928

Applied the patch, testsuite adapted.
Added test program to testsuite webtbs/tw16773.pp

Thanks for the patch !

Arnaud Bouchez

2014-11-11 10:11

reporter   ~0079087

Reported to work as expected, according to our testing!
See http://synopse.info/forum/viewtopic.php?pid=13502#p13502

Thanks!

Issue History

Date Modified Username Field Change
2014-09-24 18:03 Arnaud Bouchez New Issue
2014-09-24 18:03 Arnaud Bouchez File Added: SourceBug.dpr
2014-09-24 18:44 Arnaud Bouchez Tag Attached: interface
2014-09-24 18:44 Arnaud Bouchez Tag Attached: RTTI
2014-09-24 21:30 EgonHugeist/ZeosDevTeam Note Added: 0077611
2014-11-05 23:18 Michael Van Canneyt Assigned To => Michael Van Canneyt
2014-11-05 23:18 Michael Van Canneyt Status new => assigned
2014-11-05 23:24 Michael Van Canneyt Fixed in Revision => 28997
2014-11-05 23:24 Michael Van Canneyt Note Added: 0078928
2014-11-05 23:24 Michael Van Canneyt Status assigned => resolved
2014-11-05 23:24 Michael Van Canneyt Fixed in Version => 2.7.1
2014-11-05 23:24 Michael Van Canneyt Resolution open => fixed
2014-11-05 23:24 Michael Van Canneyt Target Version => 2.8.0
2014-11-11 10:11 Arnaud Bouchez Note Added: 0079087
2014-11-11 10:11 Arnaud Bouchez Status resolved => closed
2014-11-19 14:44 Jonas Maebe Relationship added related to 0027044
2015-03-14 14:37 Jonas Maebe Relationship added related to 0027668