Re: [fpc-pascal] Legitimate use of for and break

2023-06-16 Thread Mattias Gaertner via fpc-pascal
On Fri, 16 Jun 2023 20:51:42 +0700 Hairy Pixels via fpc-pascal wrote: > > On Jun 16, 2023, at 6:23 PM, Thomas Kurz via fpc-pascal > > wrote: > > > > Whether it's elegant is a different question. In my opinion YES > > because it often gives better readable code than nested "if" > > statements in

Re: [fpc-pascal] Legitimate use of for and break

2023-06-16 Thread Hairy Pixels via fpc-pascal
> On Jun 16, 2023, at 6:23 PM, Thomas Kurz via fpc-pascal > wrote: > > Whether it's elegant is a different question. In my opinion YES because it > often gives better readable code than nested "if" statements inside the loop. > But I've also read that using "break" is discouraged because it

Re: [fpc-pascal] Wrong assignment detected only run time without warning

2023-06-16 Thread Giuliano Colla via fpc-pascal
Il 16/06/23 15:02, Tomas Hajny via fpc-pascal ha scritto: If you compile with -CO, you should get at least a hint (if you enable displaying them, of course): I believed that -Co was enough. I'll add -CO to the debug options. Thanks. Giuliano ___

Re: [fpc-pascal] Wrong assignment detected only run time without warning

2023-06-16 Thread Tomas Hajny via fpc-pascal
On 2023-06-16 13:46, Giuliano Colla via fpc-pascal wrote: Il 16/06/23 13:36, Peter B via fpc-pascal ha scritto: Yes. Assigning a 64bit integer to a 32bit one is fine as long as the range is within bounds. Range of a variable can only be checked at run time. I can understand that. But the com

Re: [fpc-pascal] Wrong assignment detected only run time without warning

2023-06-16 Thread Giuliano Colla via fpc-pascal
Il 16/06/23 13:36, Peter B via fpc-pascal ha scritto: Yes. Assigning a 64bit integer to a 32bit one is fine as long as the range is within bounds. Range of a variable can only be checked at run time. I can understand that. But the compiler generates quite a number of warning for potential lo

Re: [fpc-pascal] Wrong assignment detected only run time without warning

2023-06-16 Thread Peter B via fpc-pascal
On 16/06/2023 11:55, Giuliano Colla via fpc-pascal wrote: Is that the intended behavior of compiler? Yes. Assigning a 64bit integer to a 32bit one is fine as long as the range is within bounds. Range of a variable can only be checked at run time. ___

Re: [fpc-pascal] Legitimate use of for and break

2023-06-16 Thread Thomas Kurz via fpc-pascal
I'm certainly not the expert in FPC's details, so maybe there'll you'll get a better answer. I just tell you my point of view. >> It's an array with a terminator >>string? Probably the length of the array should be set instead of >>doing string compares every loop. > > I need to set it in the var

[fpc-pascal] Wrong assignment detected only run time without warning

2023-06-16 Thread Giuliano Colla via fpc-pascal
I made a stupid error. My code: TFileObj = Class(TObject) [snip] Size: Integer; [snip] end; procedure TForm1.FillDir(FileData : TSearchRec); ... FFIleObj.Size := FileData.Size; ... but TSearchRec structure is: TRawbyteSearchRec = Record [snip] Size : Int64;