@@ -1040,3 +1040,72 @@ sub const_udt_array( byref s as const shape )
10401040 WARN( 0 )
10411041 print s.points( 0 ).x
10421042end sub
1043+
1044+ '' --------------------------------------------------------
1045+
1046+ '' from https://www.freebasic.net/forum/viewtopic.php?f=17&t=27692
1047+ '' and https://sourceforge.net/p/fbc/bugs/910/
1048+
1049+ #print "---- Regression Checks"
1050+
1051+ sub const_cast_string1( byval s as string )
1052+ end sub
1053+ sub const_cast_string2( byref s as const string )
1054+ WARN( 1 )
1055+ const_cast_string1( cast( string , s) )
1056+ end sub
1057+
1058+ scope
1059+ dim x as const string = "test"
1060+ dim y as string
1061+ WARN( 1 )
1062+ y = cast( string , x )
1063+ WARN( 0 )
1064+ y = cast( const string , x )
1065+ end scope
1066+
1067+ type T_integer
1068+ __ as integer
1069+ end type
1070+
1071+ sub const_cast_proc1i( byval i as integer ptr )
1072+ end sub
1073+ sub const_cast_proc2i( byval i as const integer ptr )
1074+ end sub
1075+
1076+ sub const_cast_proc1t( byval x as T_integer ptr )
1077+ end sub
1078+ sub const_cast_proc2t( byval x as const T_integer ptr )
1079+ end sub
1080+
1081+ scope
1082+ dim i as const integer = 1
1083+ WARN( 1 )
1084+ const_cast_proc1i( @cast( integer , i) )
1085+ WARN( 0 )
1086+ const_cast_proc2i( @cast( const integer , i) )
1087+ end scope
1088+
1089+ scope
1090+ dim i as integer = 1
1091+ WARN( 1 )
1092+ const_cast_proc2i( @cast( const integer , i) )
1093+ WARN( 0 )
1094+ const_cast_proc2i( @cast( integer , i) )
1095+ end scope
1096+
1097+ scope
1098+ dim x as const T_integer = ( 1 )
1099+ WARN( 1 )
1100+ const_cast_proc1t( @cast(T_integer, x) )
1101+ WARN( 0 )
1102+ const_cast_proc2t( @cast( const T_integer, x) )
1103+ end scope
1104+
1105+ scope
1106+ dim x as T_integer = ( 1 )
1107+ WARN( 1 )
1108+ const_cast_proc2t( @cast( const T_integer,x) )
1109+ WARN( 0 )
1110+ const_cast_proc2t( @cast(T_integer,x) )
1111+ end scope
0 commit comments