<p>Am 09.06.2016 00:05 schrieb "José Mejuto" <<a href="mailto:joshyfun@gmail.com">joshyfun@gmail.com</a>>:<br>
> -----------------------<br>
> program testpossiblebug;<br>
><br>
> type<br>
> TFirstRecord=record<br>
> Ident: pchar;<br>
> end;<br>
><br>
> const<br>
> TSomePcharArray: array [0..1] of pchar = ( 'pcharONE','pcharTWO');<br>
><br>
> {$DEFINE THISDONTCOMPILE}<br>
><br>
> TConstRecord: TFirstRecord = (<br>
> {$IFDEF THISDONTCOMPILE}<br>
> Ident: TSomePcharArray[1]<br>
> {$ELSE}<br>
> Ident: @TSomePcharArray[1]<br>
> {$ENDIF}<br>
> );<br>
><br>
> var<br>
> R: TFirstRecord;<br>
><br>
> begin<br>
> R:=TConstRecord;<br>
> {$IFDEF THISDONTCOMPILE}<br>
> writeln(R.Ident);<br>
> {$ELSE}<br>
> writeln(PPchar(R.Ident)^);<br>
> {$ENDIF}<br>
> end.<br>
> ------------------------<br>
><br>
> This does not compile and outputs the funny error in the subject. I think it should compile as information is static and previously defined, but if it is indeed an error by my side maybe the error message should be a bit different :-?<br>
><br>
> To test the example, define or undefine the "THISDONTCOMPILE", with it defined it does not compile, without it it compiles and the modified writeln shows the expected pchar string.<br>
><br>
> Should I report it ?</p>
<p>One can only use untyped constants to initialize other constants or variables in their declarations. The TsomePCharArray is a typed constant, thus not suitable for assignments (a pointer to it's element is however legal as you noticed).</p>
<p>Don't know how easy it would be to print a better error message...</p>
<p>Regards,<br>
Sven</p>