View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0035873 | FPC | Compiler | public | 2019-07-22 00:59 | 2019-09-17 11:37 |
Reporter | Timm Thaler | Assigned To | Jonas Maebe | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | resolved | Resolution | no change required | ||
Platform | AVR | OS | embedded | ||
Product Version | 3.3.1 | ||||
Summary | 0035873: AVR: Enumerations always use 32 bit variables | ||||
Description | Enumerations always use 32 bit variables. According to description (https://wiki.freepascal.org/Enum_Type/de) enum type should be as small as possible. | ||||
Steps To Reproduce | type Tnum = (eins, zwei, drei); var a, b : uint16; n : Tnum; m : (one, two, three, four, five); procedure testtest(); begin if (m = three) or (n = drei) then begin end; end; begin repeat n := zwei; m := four; until false; end. compiles to PsTEST_ss_TESTTEST: .Lc2: # [test.lpr] # [14] begin # [15] if (m = three) or (n = drei) then begin lds r20,(U_sPsTEST_ss_M) lds r18,(U_sPsTEST_ss_M+1) lds r21,(U_sPsTEST_ss_M+2) lds r19,(U_sPsTEST_ss_M+3) cpi r20,2 cpc r18,r1 cpc r21,r1 cpc r19,r1 breq .Lj5 lds r21,(U_sPsTEST_ss_N) lds r19,(U_sPsTEST_ss_N+1) lds r18,(U_sPsTEST_ss_N+2) lds r20,(U_sPsTEST_ss_N+3) cpi r21,2 cpc r19,r1 cpc r18,r1 cpc r20,r1 brne .Lj7 .Lj5: .Lj7: # [18] end; ret # [22] n := zwei; ldi r18,1 sts (U_sPsTEST_ss_N),r18 sts (U_sPsTEST_ss_N+1),r1 sts (U_sPsTEST_ss_N+2),r1 sts (U_sPsTEST_ss_N+3),r1 # [23] m := four; ldi r18,3 sts (U_sPsTEST_ss_M),r18 sts (U_sPsTEST_ss_M+1),r1 sts (U_sPsTEST_ss_M+2),r1 sts (U_sPsTEST_ss_M+3),r1 | ||||
Additional Information | Strange: With parser mode -MDelphi enumerations uses 8 bit, with all other parser modes -Mfpc, -MPbjFPC... enumerations uses 32 bit. Small variables can be forced with {$PACKENUM 1}. | ||||
Tags | AVR | ||||
Fixed in Revision | |||||
FPCOldBugId | |||||
FPCTarget | - | ||||
Attached Files |
|
|
The wiki is wrong. See the official documentation for the actual behaviour, and for how to modify it: https://www.freepascal.org/docs-html/current/prog/progsu59.html |
Date Modified | Username | Field | Change |
---|---|---|---|
2019-07-22 00:59 | Timm Thaler | New Issue | |
2019-07-22 10:21 | Jonas Maebe | Assigned To | => Jonas Maebe |
2019-07-22 10:21 | Jonas Maebe | Status | new => resolved |
2019-07-22 10:21 | Jonas Maebe | Resolution | open => no change required |
2019-07-22 10:21 | Jonas Maebe | FPCTarget | => - |
2019-07-22 10:21 | Jonas Maebe | Note Added: 0117342 | |
2019-09-17 11:37 | Dimitrios Chr. Ioannidis | Tag Attached: AVR |