[solved] strange behavior with constant set lazarus / 31-LCL ---------------------------------------------------------------------- Joanna · 2024-09-05 05:12 I'm trying to load a set of integer values into a combobox It seems like it doesn't work correctly when set is passed as a parameter if I try to send the set to load into combobox as a parameter it ignores the 102..105 part of set. If i send a set [0..105] it stops loading when it gets to 31 items. if I send [102..105] as a parameter it says its an empty set and loads nothing If i use a locally declared set it works perfectly Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i PROCEDURE TINI_COMBOBOX.ASSIGN( CONST ASET: TINTEGERSET) ;           const VALS = [0..7,102..105]; // this works ok if i use this one           VAR X:INTEGER; BEGINClear; //FOR X IN VALS DO  // this works perfectly // AddItem(X.ToString,NIL);FOR X IN ASET DO // this can't load the higher numbers     AddItem(X.ToString,NIL);END;   anyone know what would cause such strange behavior? using win 7 Lazarus 2.0.12 r64642 FPC 3.2.0 x86_64-win64-win32/win64 ---------------------------------------------------------------------- ASerge · 2024-09-05 06:01 Quote from: Joanna on September 05, 2024, 07:12:34 amanyone know what would cause such strange behavior? Not strange, because TIntegerSet = [0..31]. ---------------------------------------------------------------------- MarkMLl · 2024-09-05 06:02 What appears to be happening is that the set type is defaulting to one with 32 elements, i.e. the same as an integer. I'm not sure what the limitation on the number of elements in a set is these days but it won't be large. However what you want to do is set up a type with that number of elements, and then use that type explicitly when setting up a constant, passing a parameter and so on. You might need to distill this down to a compilable test program: SOP, sorry but I shouldn't have to mention it. MarkMLl ---------------------------------------------------------------------- Joanna · 2024-09-05 06:16 I always thought that sets had 255 elements possible with ordinal or positive integers . I never heard of 32 element set before. I’m not sure how to create a larger set type it won’t let me. ---------------------------------------------------------------------- dseligo · 2024-09-05 06:21 Quote from: Joanna on September 05, 2024, 08:16:36 amI always thought that sets had 255 elements possible with ordinal or positive integers . I never heard of 32 element set before. According to manual, you are right (256, not 255): https://www.freepascal.org/docs-html/3.2.0/ref/refsu16.html ---------------------------------------------------------------------- Joanna · 2024-09-05 06:32 I was thinking 0 to 255  Is there any way to prevent the set from being messed up when it’s sent as a parameter ? ---------------------------------------------------------------------- cdbc · 2024-09-05 06:37 Hi QuoteIs there any way to prevent the set from being messed up when it’s sent as a parameter ?Yes, define your own set type that holds more than 0..31... e.g.:Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i type   TJIntSet = set of 0..255;Regards Benny ---------------------------------------------------------------------- Joanna · 2024-09-05 06:48 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i PROCEDURE TNUM_COL_FILTER.TEST;           TYPE BIGSET = SET OF 0..255;           CONST           VALS:BIGSET = [0..7,102..105]; BEGIN  COMBOBOX.Assign(VALS);END; i tried this and it compiles just fine but ignores the 102..105 part ---------------------------------------------------------------------- MarkMLl · 2024-09-05 07:00 Quote from: dseligo on September 05, 2024, 08:21:04 amAccording to manual, you are right (256, not 255): https://www.freepascal.org/docs- html/3.2.0/ref/refsu16.html Noting that that's the maximum size, not the default. QuoteHow many bytes the compiler uses to store a sets depends on the mode. For non-Delphi modes, the compiler stores small sets (less than 32 elements) in a Longint, if the set element type range allows it. This allows for faster processing and decreases program size. Otherwise, sets are stored in 32 bytes. And I expect that OP's got range checking etc. turned off. MarkMLl ---------------------------------------------------------------------- cdbc · 2024-09-05 07:15 Hi I meant use the new type here:Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i PROCEDURE TINI_COMBOBOX.ASSIGN( CONST ASET: TJIntSet) ; //<---HERERegards Benny ---------------------------------------------------------------------- jamie · 2024-09-05 11:09 For a test, and this would confirm if there were an issue building a SET parameter for the function of that or I am just blowing smoke! have you tried using a CONSTREF instead of CONST? ---------------------------------------------------------------------- Joanna · 2024-09-05 13:58 Quote from: jamie on September 05, 2024, 01:09:53 pmFor a test, and this would confirm if there were an issue building a SET parameter for the function of that or I am just blowing smoke! have you tried using a CONSTREF instead of CONST? I’m not sure what a consfref is? Quote And I expect that OP's got range checking etc. turned off. MarkMLl that’s a bizarre accusation. Why would I not want range checking? I’m using fpc mode but I never knew about the default set being truncated. Cdbc I tried what you told me and it works. I’m still flabbergasted That it would truncate a set rather than adjust to the size needed. Thanks everyone for the insights ---------------------------------------------------------------------- MarkMLl · 2024-09-05 14:13 Quote from: Joanna on September 05, 2024, 03:58:47 pmQuote And I expect that OP's got range checking etc. turned off. MarkMLl that’s a bizarre accusation. Why would I not want range checking? I’m still flabbergasted That it would truncate a set rather than adjust to the size needed. If your range checking is on but a set is being truncated without warning at either compilation or runtime, my own feeling is that that should be considered an error. But you'd not posted a compilable example or told us exactly how you were building... /fortunately/ we can't all read your mind. Somebody's mentioned that sets can contain 256 elements, but that is the /maximum/ number they can contain, and the manual is explicit that by default they're a longint... you did read that bit I quoted, didn't you? So what's happening is that because you hadn't specified a set type it was defaulting to 32 elements, but then- apparently- silently discarding bits from an allocation. That's /wrong/, but at the same time your use of an implicit set type in that parameter list was arguably a bit dodgy... only a bit though, and I can sympathise. There's a related problem where the shifting operator silently ignores an operand of larger than (I think) 31. MarkMLl ---------------------------------------------------------------------- Bart · 2024-09-05 21:25 It seems that at least Delphi 7 behaves similar. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program test;{$ifdef fpc}{$mode objfpc}{$h+}//{$mode delphi}{$endif}{$apptype console} uses  sysutils; Var  Z: TIntegerSet;  L: LongInt absolute Z;  //using typecast here since D7 cannot do for..in loopbegin  {$R+}  if SizeOf(TIntegerSet) <> SizeOf(LongInt) then RunError(1);  Z := [0,28];  writeln(IntToHex(L,4));  Z := [0,28,101,102];  writeln(IntToHex(L,4));end.Code: [Select]C:\Users\Bart\LazarusProjecten\ConsoleProjecten>fpc test.pas Free Pascal Compiler version 3.3.1 [2024/03/12] for i386 ... 26 lines compiled, 0.2 sec, 73024 bytes code, 4580 bytes data 1 warning(s) issued C:\Users\Bart\LazarusProjecten\ConsoleProjecten>test 10000001 10000001 C:\Users\Bart\LazarusProjecten\ConsoleProjecten>dcc32 test.pas Borland Delphi Version 15.0 Copyright (c) 1983,2002 Borland Software Corporation test.pas(27) 28 lines, 0.03 seconds, 29244 bytes code, 2973 bytes data. C:\Users\Bart\LazarusProjecten\ConsoleProjecten>test 10000001 10000001 As you can see both sets [0,28] and [0,28,101,102] are the same and no runtime error occurs with RangeChecking on. Bart ---------------------------------------------------------------------- Joanna · 2024-09-05 22:38 Markml that might explain the cutting off adding things at 31 items but it doesn’t explain it ignoring the set of values over 100. They are perfectly valid. So there are really two issues, the truncating at 31 items and the ignoring a set of higher values. ---------------------------------------------------------------------- jamie · 2024-09-06 00:47 Quote There's a related problem where the shifting operator silently ignores an operand of larger than (I think) 31. MarkMLl That problem is based on the CPU behavior because only the first 5 bits of the register are used which gives you the full range for a 32 bit object.    I don't know how the compiler handles it but if a greater Than 31 is placed in the register then you'll get a MOD effect of course where only the remainder is going to be valid.  Basically the CPU ignores the rest in the register.  64 bit registers of course monitor more bits, should be 6 bits by my account, operated on a 2-bit OS. Jamie ---------------------------------------------------------------------- MarkMLl · 2024-09-06 06:02 Quote from: Joanna on September 06, 2024, 12:38:09 amMarkml that might explain the cutting off adding things at 31 items but it doesn’t explain it ignoring the set of values over 100. They are perfectly valid. So there are really two issues, the truncating at 31 items and the ignoring a set of higher values. So raise it as a bug. MarkMLl ---------------------------------------------------------------------- Joanna · 2024-09-06 21:39 Quote from: MarkMLl on September 06, 2024, 08:02:34 amQuote from: Joanna on September 06, 2024, 12:38:09 amMarkml that might explain the cutting off adding things at 31 items but it doesn’t explain it ignoring the set of values over 100. They are perfectly valid. So there are really two issues, the truncating at 31 items and the ignoring a set of higher values. So raise it as a bug. MarkMLl That sounds like a great idea, unfortunately everytime I go to the bug tracker I get a blank page and can do nothing!! No wait I take that back if I try to register an account it gives me a bunch of captchas. I don’t think an account would help much for a blank page anyway.. ---------------------------------------------------------------------- MarkMLl · 2024-09-07 07:43 Quote from: Joanna on September 06, 2024, 11:39:29 pmThat sounds like a great idea, unfortunately everytime I go to the bug tracker I get a blank page and can do nothing!! No wait I take that back if I try to register an account it gives me a bunch of captchas. I don’t think an account would help much for a blank page anyway.. For $deity's sake Joanna! I'm a complete holdout as far as invasive technology goes, but even I make sure can use the bug tracker... and being able to report bugs when one finds them is pretty much a prerequisite if one wants to be a responsible member of the community. Here's what I've got, and I assure you that it's much more tightly managed than most peoples'. * Up-to-date Debian Linux with KDE desktop. * Firefox as web browser (there's a small number of cases where I find using a different browser to be useful. This isn't one of them. * The browser is started with these parameters edited into the appropriate desktop menu: Code: [Select]-ProfileManager -no-remote %u * I have multiple separate profiles, generally active at the same time. ** By default, all Javascript, Java etc. is disabled. I use this as the first-level tool for all blogs etc. that I don't trust as well as for Google searches. ** I then have one with scripting etc. enabled but with everything set to strict security, with NoScript installed and set to block everything that isn't specifically enabled. ** I have others for social media etc. which I assume contains toxic links. Gmail, the FPC/Lazarus forum, and the GitLabs bug tracker (which replaced Mantis) run on the second of those. All caching, scripting, plugins etc. are kept separate, so unless some nasty bit of Javascript picked up via Youtube managed to break out of Firefox's sandbox or break the underlying operating system's security it wouldn't be able to get at my banking activities etc. The only downside that bites me occasionally is that if an arbitrary program tries to fire up a new browser instance it has problems if the default profile is already running. I've not investigated but that might be something to do with the -no-remote option: TBH I can't remember why I've got that. So seriously Joanna: if you're to be taken as anything more than an irritant you need to get your act together. Refusing to report bugs is anti-social. MarkMLl ---------------------------------------------------------------------- BrunoK · 2024-09-07 10:33 Defined in rtl\objpas\sysutils\sysutilh.inc, ~line 43 as Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i    TIntegerSet = Set of 0..SizeOf(Integer)*8-1;So, as per James, cannot set a bit <0 or >31. ---------------------------------------------------------------------- MarkMLl · 2024-09-07 10:53 Quote from: BrunoK on September 07, 2024, 12:33:05 pmDefined in rtl\objpas\sysutils\sysutilh.inc, ~line 43 as Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i    TIntegerSet = Set of 0..SizeOf(Integer)*8-1;So, as per James, cannot set a bit <0 or >31. But the issue is that an initial declaration like [0..7,102..105] is getting truncated to 32 bits without warning: that shouldn't happen. MarkMLl ---------------------------------------------------------------------- Thaddy · 2024-09-07 11:31 I don't see the problem either way:Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program maxset; type  bigenum = (  S0,S1,S2,S3,S4,S5,S6,S7,S8,S9,S10,  S11,S12,S13,S14,S15,S16,S17,S18,S19,S20,  S21,S22,S23,S24,S25,S26,S27,S28,S29,S30,  S31,S32,S33,S34,S35,S36,S37,S38,S39,S40,  S41,S42,S43,S44,S45,S46,S47,S48,S49,S50,  S51,S52,S53,S54,S55,S56,S57,S58,S59,S60,  S61,S62,S63,S64,S65,S66,S67,S68,S69,S70,  S71,S72,S73,S74,S75,S76,S77,S78,S79,S80,  S81,S82,S83,S84,S85,S86,S87,S88,S89,S90,  S91,S92,S93,S94,S95,S96,S97,S98,S99,S100,  S101,S102,S103,S104,S105,S106,S107,S108,S109,S110,  S111,S112,S113,S114,S115,S116,S117,S118,S119,S120,  S121,S122,S123,S124,S125,S126,S127,S128,S129,S130,  S131,S132,S133,S134,S135,S136,S137,S138,S139,S140,  S141,S142,S143,S144,S145,S146,S147,S148,S149,S150,  S151,S152,S153,S154,S155,S156,S157,S158,S159,S160,  S161,S162,S163,S164,S165,S166,S167,S168,S169,S170,  S171,S172,S173,S174,S175,S176,S177,S178,S179,S180,  S181,S182,S183,S184,S185,S186,S187,S188,S189,S190,  S191,S192,S193,S194,S195,S196,S197,S198,S199,S200,  S201,S202,S203,S204,S205,S206,S207,S208,S209,S210,  S211,S212,S213,S214,S215,S216,S217,S218,S219,S220,  S221,S222,S223,S224,S225,S226,S227,S228,S229,S230,  S231,S232,S233,S234,S235,S236,S237,S238,S239,S240,  S241,S242,S243,S244,S245,S246,S247,S248,S249,S250,  S251,S252,S253,S254,S255); TBigSet = bitpacked set of bigenum; procedure acceptbigset(var s:TBigset);begin include(s, S251); include(s, S1);end; var s:TBigSet =[]; e:BigEnum;begin acceptbigset(s); for e in s do writeln(e);end. ---------------------------------------------------------------------- MarkMLl · 2024-09-07 12:14 Quote from: Thaddy on September 07, 2024, 01:31:48 pmI don't see the problem either way: Go back and read the thread. OP's trying to assign bits > 31 to a TIntegerSet, which is defined as https://www.freepascal.org/docs-html/rtl/sysutils/tintegerset.html (i.e. 32 elements for the browser-impaired), but is getting no compile-time warning or error. That's /wrong/. MarkMLl ---------------------------------------------------------------------- Thaddy · 2024-09-07 12:37 That is indeed wrong. I missed that, not because of my browser but because of shout case. ---------------------------------------------------------------------- MarkMLl · 2024-09-07 13:05 Quote from: Thaddy on September 07, 2024, 02:37:37 pmThat is indeed wrong. I missed that, not because of my browser but because of shout case. Don't worry, it's not easy to follow particularly since OP has refused to provide a compilable test case (and can't be relied on to follow links to documentation etc., hence my "browser-impaired" dig which definitely wasn't aimed at you). MarkMLl ---------------------------------------------------------------------- Joanna · 2024-09-07 14:39 Quote So seriously Joanna: if you're to be taken as anything more than an irritant you need to get your act together. Refusing to report bugs is anti-social. I found some bugs and reported them to everyone who reads my posts. If anyone is antisocial it’s the people who refuse to help me get them into bug tracker when it’s obvious I’m having technical difficulties and choose to berate me instead. That’s a fine way to reward someone for finding a bug. Maybe I should just pretend bugs don’t exist in the future, so I won’t get blamed for their existence. ---------------------------------------------------------------------- Thaddy · 2024-09-07 14:46 No, you should learn to write proper bug reports with proper full code, reproducable or not. You could have written my example above, although out-of-context as Mark pointed out, it is full code. ---------------------------------------------------------------------- Joanna · 2024-09-07 15:04 @thaddy I’ve never seen include procedure before. What unit is it in? And what happened when you ran program? ---------------------------------------------------------------------- MarkMLl · 2024-09-07 15:18 Quote from: Joanna on September 07, 2024, 05:04:50 pm@thaddy I’ve never seen include procedure before. What unit is it in? And what happened when you ran program? https://www.freepascal.org/docs-html/current/rtl/system/include.html Joanna, get off your arse and use the bug report system. "I found some bugs and reported them to everyone who reads my posts." is utterly meaningless, and I've obviously been wasting my time trying to give you some pointers how to use a modern browser safely. MarkMLl ---------------------------------------------------------------------- Joanna · 2024-09-07 16:38 Sorry, the gitlab site doesn’t work on my other computer either... Could someone who has access to gitlab please post the bugs I’ve found? This is so petty. I’ve done my part finding and sharing bugs. I give up! Maybe the bug tracker should be in a place that is easier to use. ---------------------------------------------------------------------- Joanna · 2024-09-07 17:05 gitlab will not even let me create an account! What a ridiculous website the bug tracker is on.