Re: [fpc-pascal] New Warnings with fpc >= 3.2.0 (fredvs)

2020-03-14 Thread fredvs via fpc-pascal
Hello Sven. OK, perfectly explained. Many thanks for all that infos. (It was needed to become Doctor es Enum). And a trick from a Doctor es Enum: "Always initialize by your self your enum before to use it". Fre;D - Many thanks ;-) -- Sent from: http://free-pascal-general.1045716.n5.na

Re: [fpc-pascal] New Warnings with fpc >= 3.2.0 (fredvs)

2020-03-14 Thread Sven Barth via fpc-pascal
Am 14.03.2020 um 17:18 schrieb fredvs via fpc-pascal: Hi Sven, sorry to come back, (dont forget I am a enum-guru now). But to be totally logic, in the previous code: if kind = tabulatorkindty(0) then Should it not be something illegal because of definition: tabulatorkindty = (tak_none := 1,

Re: [fpc-pascal] New Warnings with fpc >= 3.2.0

2020-03-14 Thread fredvs via fpc-pascal
> as there are a lot of messages in this thread Yes, it is an epidemic, and it has already muted there: http://free-pascal-general.1045716.n5.nabble.com/Re-New-Warnings-with-fpc-gt-3-2-0-fredvs-td5735027.html You will see with last message that all is not so simple: Initialization of a enum-va

Re: [fpc-pascal] New Warnings with fpc >= 3.2.0

2020-03-14 Thread Andrew Hall via fpc-pascal
Apologies if already suggested as there are a lot of messages in this thread - but would this meet your needs: tabulatorkindty = (tak_none=-1,tak_left,tak_right,tak_centered,tak_decimal); This ensures -1 is a valid enum value so tabulatorkindty(-1) should not raise a warning (I’ve not tried it

Re: [fpc-pascal] New Warnings with fpc >= 3.2.0 (fredvs)

2020-03-14 Thread fredvs via fpc-pascal
Hi Sven, sorry to come back, (dont forget I am a enum-guru now). But to be totally logic, in the previous code: > if kind = tabulatorkindty(0) then Should it not be something illegal because of definition: > tabulatorkindty = > (tak_none := 1,tak_left,tak_right,tak_centered,tak_decimal); th

Re: [fpc-pascal] New Warnings with fpc >= 3.2.0 (fredvs)

2020-03-14 Thread fredvs via fpc-pascal
> much better to put it first in the list for numerous reasons... Not sure it is much better but, yes, I will do it with the "better boy" way. Thanks. Fre;D - Many thanks ;-) -- Sent from: http://free-pascal-general.1045716.n5.nabble.com/ ___

Re: [fpc-pascal] New Warnings with fpc >= 3.2.0 (fredvs)

2020-03-14 Thread fredvs via fpc-pascal
> And it's not initialized with the first item, but with 0. Well said, indeed, that example (see tak_none := 1): PROGRAM enumtest; type tabulatorkindty = (tak_none := 1,tak_left,tak_right,tak_centered,tak_decimal); var kind: tabulatorkindty; begin if kind = tak_none then Writ

Re: [fpc-pascal] New Warnings with fpc >= 3.2.0 (fredvs)

2020-03-14 Thread wkitty42
On 3/14/20 10:18 AM, fredvs via fpc-pascal wrote: Yes, that is the main problem. If you do it the "logical" way, placing at first without initialization, when ord(kind) is used in code, because the order has changed, lot of code must be re-written. i don't see a problem with that... only some t

Re: [fpc-pascal] New Warnings with fpc >= 3.2.0 (fredvs)

2020-03-14 Thread Sven Barth via fpc-pascal
fredvs via fpc-pascal schrieb am Sa., 14. März 2020, 13:01: > So, thanks for the tip, "kind" seems indeed initialized with first item. > Please note that this is only true for global variables and fields of classes. And it's not initialized with the first item, but with 0. Regards, Sven >

Re: [fpc-pascal] New Warnings with fpc >= 3.2.0 (fredvs)

2020-03-14 Thread fredvs via fpc-pascal
>Note that if you depend on this technique you should add a comment where the type is defined that the order of the items is > significant so that someone in the future does not change the order out of > ignorance! Yes, that is the main problem. If you do it the "logical" way, placing at first wit

Re: [fpc-pascal] New Warnings with fpc >= 3.2.0 (fredvs)

2020-03-14 Thread DougC
Note that if you depend on this technique you should add a comment where the type is defined that the order of the items is significant so that someone in the future does not change the order out of ignorance!___ fpc-pascal maillist - fpc-pascal@lists

Re: [fpc-pascal] New Warnings with fpc >= 3.2.0 (fredvs)

2020-03-14 Thread fredvs via fpc-pascal
Hello BrunoK >so a field in an object is by default initialized to tak_none during the > object's creation. Hum, doing this: _ PROGRAM enumtest; type tabulatorkindty = (tak_none,tak_left,tak_right,tak_centered,tak_decimal); var kind: tabulatorkindty; begin if k

Re: [fpc-pascal] New Warnings with fpc >= 3.2.0 (fredvs)

2020-03-14 Thread KBruno Id2
A possibility, using your enumeration is to change it from tabulatorkindty = (tak_left,tak_right,tak_centered,tak_decimal, tak_none); to tabulatorkindty = (tak_none,tak_left,tak_right,tak_centered,tak_decimal); so a field in an object is by default initialized to tak_none during the object's

Re: [fpc-pascal] New Warnings with fpc >= 3.2.0

2020-03-13 Thread fredvs via fpc-pascal
> type Set_Of_tabulatorkindty= set of tabulatorkindty; Yes, it was proposed too. It has the advantage to fix the tabulatorkindty(-1) bug without adding a new item-enum. But the disadvantage is: lot of change in code, maybe more than simply adding "tak_nil" at end of the enum-array. And initiali

Re: [fpc-pascal] New Warnings with fpc >= 3.2.0

2020-03-13 Thread Santiago A.
El 11/03/2020 a las 16:37, wkitt...@windstream.net escribió: On 3/11/20 11:35 AM, fredvs via fpc-pascal wrote: f (kind in tabulatorkindty) then Yes, I like it! But, sadly, the compiler no. "Error: Operator is not overloaded"... that's weird... i thought that construct was standard for arr

Re: [fpc-pascal] New Warnings with fpc >= 3.2.0

2020-03-13 Thread fredvs via fpc-pascal
> ---> kind := tabulatorkindty(-1); > makes no sense. Yes of course, it is the reason of that topic. fpc 3.0.4 does not give any warning for this (strange...). And it is fpc 3.2.0 that reveals that bug, giving a warning for that. Note that fpc 3.2.0 is still tolerant, with a strict compiler, the

Re: [fpc-pascal] New Warnings with fpc >= 3.2.0

2020-03-13 Thread Santiago A.
El 13/03/2020 a las 15:49, fredvs via fpc-pascal escribió: Hello Santiago. What do you think? IMHO ---> kind := tabulatorkindty(-1); makes no sense. Why should you initialize a variable on purpose to an out-of-range value? If you need a sentinel value, or a non valid value, create one, like

Re: [fpc-pascal] New Warnings with fpc >= 3.2.0

2020-03-13 Thread fredvs via fpc-pascal
Hello Santiago. > I supposse you are reading from a format that stores > tabulatorkindty value as an integer No, imho it was a bug, tabulatorkindty is a enumeration array and using integer instead of a enum is not ok. > if (intValue>=ord(Low(tabulatorkindty))) and > (intValue<=ord(high(tabulato

Re: [fpc-pascal] New Warnings with fpc >= 3.2.0

2020-03-13 Thread Santiago A.
El 11/03/2020 a las 11:15, fredvs via fpc-pascal escribió: ---> tabulatorkindty = (tak_left,tak_right,tak_centered,tak_decimal,tak_none); ? And then use: ---> if (kind <> tabulatorkindty(tak_none) ? Or do you have a other idea? Yes, for my taste that is the way to go. But you don't need t

Re: [fpc-pascal] New Warnings with fpc >= 3.2.0

2020-03-12 Thread fredvs via fpc-pascal
> ( and that can be considered, imho, as a bug). I was talking about mse code, not new behavior of warning of fpc 3.2.0. Fre;D - Many thanks ;-) -- Sent from: http://free-pascal-general.1045716.n5.nabble.com/ ___ fpc-pascal maillist - fpc-pasc

Re: [fpc-pascal] New Warnings with fpc >= 3.2.0

2020-03-12 Thread fredvs via fpc-pascal
> which will make it always true. I see no reason for that "if" to exists > at least not with out the code. Yes I know, it is strange. But, like explained Roland Chastain in a other topic: > With FPC 3.0.4, the following code compiles without warning and works: >type > tabulatorkindty = (ak_l

Re: [fpc-pascal] New Warnings with fpc >= 3.2.0

2020-03-12 Thread stdreamer via fpc-pascal
On 11/3/2020 12:15 μ.μ., fredvs via fpc-pascal wrote: Hello. Compiling that code with fpc 3.2.0 gives the warning that follows: ---> if (kind <> tabulatorkindty(-1)) --> gives now the warning: "msedrawtext.pas(1115,48) Warning: range check error while evaluating constants (-1 must be between

Re: [fpc-pascal] New Warnings with fpc >= 3.2.0

2020-03-11 Thread Sven Barth via fpc-pascal
schrieb am Mi., 11. März 2020, 16:37: > On 3/11/20 11:35 AM, fredvs via fpc-pascal wrote: > >> f (kind in tabulatorkindty) then > > > > Yes, I like it! > > > > But, sadly, the compiler no. > > > > "Error: Operator is not overloaded"... > > > that's weird... i thought that construct was standard f

Re: [fpc-pascal] New Warnings with fpc >= 3.2.0

2020-03-11 Thread wkitty42
On 3/11/20 11:35 AM, fredvs via fpc-pascal wrote: f (kind in tabulatorkindty) then Yes, I like it! But, sadly, the compiler no. "Error: Operator is not overloaded"... that's weird... i thought that construct was standard for arrays and similar... hummm... -- NOTE: No off-list assistan

Re: [fpc-pascal] New Warnings with fpc >= 3.2.0

2020-03-11 Thread fredvs via fpc-pascal
> f (kind in tabulatorkindty) then Yes, I like it! But, sadly, the compiler no. "Error: Operator is not overloaded"... Fre;D - Many thanks ;-) -- Sent from: http://free-pascal-general.1045716.n5.nabble.com/ ___ fpc-pascal maillist - fpc-pas

Re: [fpc-pascal] New Warnings with fpc >= 3.2.0

2020-03-11 Thread wkitty42
On 3/11/20 7:51 AM, fredvs via fpc-pascal wrote: if (kind = tabulatorkindty(tak_lef)) or (kind = tabulatorkindty(tak_right)) or (kind = tabulatorkindty(tak_centered)) or (kind = tabulatorkindty(tak_decimal)) then But I would prefer a shorter way, mainly if the array is big. admittedly i don't

Re: [fpc-pascal] New Warnings with fpc >= 3.2.0

2020-03-11 Thread fredvs via fpc-pascal
> You are abusing enums. Either use them correctly or not at all Hum, it is not my code but, yes I understood, I will fix it with the "good boy" way. Thanks for all that clear, fast and with solutions answers. Fre;D - Many thanks ;-) -- Sent from: http://free-pascal-general.1045716.n5

Re: [fpc-pascal] New Warnings with fpc >= 3.2.0

2020-03-11 Thread Sven Barth via fpc-pascal
fredvs via fpc-pascal schrieb am Mi., 11. März 2020, 13:25: > By the way, huh, yes, if I am totally sure that the code is safe, I would > be > happy to know the code-number of those Warning and disable it. > > Of course in last resort (no time to be lazy). > You can find out any message id by co

Re: [fpc-pascal] New Warnings with fpc >= 3.2.0

2020-03-11 Thread Sven Barth via fpc-pascal
fredvs via fpc-pascal schrieb am Mi., 11. März 2020, 12:51: > > Other question relative to Warnings: > > How to do this: > > tdataevent(de_afterapplyupdate) > > where TDataEvent is defined as > > TDataEvent = (deFieldChange, deRecordChange, deDataSetChange, > deDataSetScroll, deLayoutChange,

Re: [fpc-pascal] New Warnings with fpc >= 3.2.0

2020-03-11 Thread Sven Barth via fpc-pascal
fredvs via fpc-pascal schrieb am Mi., 11. März 2020, 11:16: > Hello. > > Compiling that code with fpc 3.2.0 gives the warning that follows: > > ---> if (kind <> tabulatorkindty(-1)) --> gives now the warning: > > "msedrawtext.pas(1115,48) Warning: range check error while evaluating > constants (

Re: [fpc-pascal] New Warnings with fpc >= 3.2.0

2020-03-11 Thread Michael Van Canneyt
On Wed, 11 Mar 2020, fredvs via fpc-pascal wrote: Thanks Michael. You'll need to disable that particular warning if you want to use such tricks. For the "-1" trick, it can be easy fixed with if (kind = tabulatorkindty(tak_lef)) or (kind = tabulatorkindty(tak_right)) or (kind = tabulato

Re: [fpc-pascal] New Warnings with fpc >= 3.2.0

2020-03-11 Thread fredvs via fpc-pascal
Thanks Michael. > You'll need to disable that particular warning if you want to use such > tricks. For the "-1" trick, it can be easy fixed with if (kind = tabulatorkindty(tak_lef)) or (kind = tabulatorkindty(tak_right)) or (kind = tabulatorkindty(tak_centered)) or (kind = tabulatorkindty(tak_

Re: [fpc-pascal] New Warnings with fpc >= 3.2.0

2020-03-11 Thread Michael Van Canneyt
On Wed, 11 Mar 2020, fredvs via fpc-pascal wrote: Do it properly, and add a tab_None or somesuch If I may, I would prefer "somesuch" vs adding a new constant. Of course you may. It is a free world. But, really, would it not possible to write the equivalent of if (kind <> tabulatorkin

Re: [fpc-pascal] New Warnings with fpc >= 3.2.0

2020-03-11 Thread fredvs via fpc-pascal
> Do it properly, and add a tab_None or somesuch If I may, I would prefer "somesuch" vs adding a new constant. But, really, would it not possible to write the equivalent of if (kind <> tabulatorkindty(-1)) then Maybe using in this case: if (kind = tabulatorkindty(tak_lef)) or (kind = tabulato

Re: [fpc-pascal] New Warnings with fpc >= 3.2.0

2020-03-11 Thread Michael Van Canneyt
On Wed, 11 Mar 2020, fredvs via fpc-pascal wrote: Re-hello. What must be changed, a new constant should be added at end of the array, Lot of work because with this the array must be initialized with tak_none. But maybe there is now a new fpc trick to write: --> if (kind <> tabulatorkindt

Re: [fpc-pascal] New Warnings with fpc >= 3.2.0

2020-03-11 Thread Marco van de Voort
Op 2020-03-11 om 11:44 schreef fredvs via fpc-pascal: PS: Imho, using "-1" was a nice trick and it is sad that it cannot more be used. It is a warning not an error. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepasca

Re: [fpc-pascal] New Warnings with fpc >= 3.2.0

2020-03-11 Thread fredvs via fpc-pascal
Re-hello. > What must be changed, a new constant should be added at end of the array, Lot of work because with this the array must be initialized with tak_none. But maybe there is now a new fpc trick to write: --> if (kind <> tabulatorkindty(-1)) That will say "if kind is different of somethi

[fpc-pascal] New Warnings with fpc >= 3.2.0

2020-03-11 Thread fredvs via fpc-pascal
Hello. Compiling that code with fpc 3.2.0 gives the warning that follows: ---> if (kind <> tabulatorkindty(-1)) --> gives now the warning: "msedrawtext.pas(1115,48) Warning: range check error while evaluating constants (-1 must be between 0 and 3)" tabulatorkindty is declared as: ---> tabulat