public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/108651] New: Array Constructor with [type-spec:: fails to apply to all values, eg x = [integer(int64):: 1,2,3,4]
@ 2023-02-03 0:23 Boyce at engineer dot com
2023-02-03 7:18 ` [Bug fortran/108651] " kargl at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Boyce at engineer dot com @ 2023-02-03 0:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108651
Bug ID: 108651
Summary: Array Constructor with [type-spec:: fails to apply to
all values, eg x = [integer(int64):: 1,2,3,4]
Product: gcc
Version: 11.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: Boyce at engineer dot com
Target Milestone: ---
Created attachment 54399
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54399&action=edit
Source code, bash file to compile, and error message
Array Constructor with type-spec:: failes to convert all values in the array.
This is similar to
Bug 48478 - Array-constructor with type-spec: reject valid/accept invalid
But the error still occurs for integer arrays.
for example,
use, intrinsic:: iso_fortran_env, only: int64
integer(int64), dimension(2), parameter:: arr1 = [integer(int64):: 1, 2]
! should be equivalent to
integer(int64), dimension(2), parameter:: arr2 = [1_int64, 2_int64]
I tested this code with with 11.3.0 and 12.1.0
I attached a simple code, the resulting error message, and bash file for
compiling to create the error.
This code has the following line:
INTEGER(INT64), dimension(2), parameter:: arr1 = [integer(int64)::
-3300711175878204139, 8258803693257250632]
which raises:
Error: Integer too big for its kind at (1). This check can be disabled with
the option ‘-fno-range-check’
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/108651] Array Constructor with [type-spec:: fails to apply to all values, eg x = [integer(int64):: 1,2,3,4]
2023-02-03 0:23 [Bug fortran/108651] New: Array Constructor with [type-spec:: fails to apply to all values, eg x = [integer(int64):: 1,2,3,4] Boyce at engineer dot com
@ 2023-02-03 7:18 ` kargl at gcc dot gnu.org
2023-02-03 7:33 ` kargl at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: kargl at gcc dot gnu.org @ 2023-02-03 7:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108651
kargl at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
CC| |kargl at gcc dot gnu.org
Last reconfirmed| |2023-02-03
Status|UNCONFIRMED |WAITING
Priority|P3 |P4
--- Comment #1 from kargl at gcc dot gnu.org ---
Works for me.
% cat a.f90
use, intrinsic:: iso_fortran_env, only: int64
integer(int64), dimension(2), parameter:: arr1 = [integer(int64):: 1, 2]
print *, arr1
end
% gfcx -o z a.f90 && ./z
1 2
This is with both 11.3.0 and 13.0.1.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/108651] Array Constructor with [type-spec:: fails to apply to all values, eg x = [integer(int64):: 1,2,3,4]
2023-02-03 0:23 [Bug fortran/108651] New: Array Constructor with [type-spec:: fails to apply to all values, eg x = [integer(int64):: 1,2,3,4] Boyce at engineer dot com
2023-02-03 7:18 ` [Bug fortran/108651] " kargl at gcc dot gnu.org
@ 2023-02-03 7:33 ` kargl at gcc dot gnu.org
2023-02-03 16:11 ` Boyce at engineer dot com
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: kargl at gcc dot gnu.org @ 2023-02-03 7:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108651
kargl at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |RESOLVED
Resolution|--- |FIXED
--- Comment #2 from kargl at gcc dot gnu.org ---
Ugh. For such a short testcase, please don't attach a zip file. Just paste it
into the comment.
% gfcx -c main.f90
main.f90:5:90:
5 | INTEGER(INT64), dimension(2), parameter:: arr1 = [integer(int64)::
-3300711175878204139, 8258803693257250632]
|
1
Error: Integer too big for its kind at (1). This check can be disabled with the
option '-fno-range-check'
This is the correct behavior. -3300711175878204139 and 8258803693257250632 are
default integer kind, which is 32 bit and both numbers are outside the range of
[-huge(1)-1:huge(1)].
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/108651] Array Constructor with [type-spec:: fails to apply to all values, eg x = [integer(int64):: 1,2,3,4]
2023-02-03 0:23 [Bug fortran/108651] New: Array Constructor with [type-spec:: fails to apply to all values, eg x = [integer(int64):: 1,2,3,4] Boyce at engineer dot com
2023-02-03 7:18 ` [Bug fortran/108651] " kargl at gcc dot gnu.org
2023-02-03 7:33 ` kargl at gcc dot gnu.org
@ 2023-02-03 16:11 ` Boyce at engineer dot com
2023-02-03 16:51 ` kargl at gcc dot gnu.org
2023-02-03 18:44 ` anlauf at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: Boyce at engineer dot com @ 2023-02-03 16:11 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108651
--- Comment #3 from Scott Boyce <Boyce at engineer dot com> ---
No its not correct because the
[integer(int64)::
in
INTEGER(INT64), dimension(2), parameter:: arr1 = [integer(int64)::
-3300711175878204139, 8258803693257250632]
is the initialization is indicating that all the numbers are int64 and not
int32.
Otherwise, what is the point of adding the type spec within the array
initialization
Second, otherwise you have to do something stupid like this to be compatible
with gfortran:
INTEGER(INT64), dimension(256), parameter:: exp_ipmf= [ &
9223372036854775806_int64, 1623796909450836942_int64,
2664290944894287536_int64, &
7387971354164062286_int64, 6515064486552725727_int64,
8840508362680705564_int64, &
6099647593382931854_int64, 7673130333659518959_int64,
6220332867583442119_int64, &
5045979640552799519_int64, 4075305837223961434_int64,
3258413672162528204_int64, &
2560664887087755460_int64, 1957224924672901793_int64,
1429800935350586317_int64, &
964606309710805398_int64, 551043923599587507_int64,
180827629096887271_int64, &
-152619738120024135_int64, -454588624410297994_int64,
-729385126147771550_int64, &
-980551509819436091_int64, -1211029700667469343_int64,
-1423284293868552853_int64, &
-1619396356369054015_int64, -1801135830956208679_int64,
-1970018048575620636_int64, &
-2127348289059702419_int64, -2274257249303686369_int64,
-2411729520096647511_int64, &
-2540626634159186189_int64, -2661705860113411427_int64,
-2775635634532452931_int64, &
-2883008316030452685_int64, -2984350790383660344_int64,
-3080133339198120492_int64, &
-3170777096303094023_int64, -3256660348483807146_int64,
-3338123885075143810_int64, &
-3415475560473292784_int64, -3488994201966436213_int64,
-3558932970354465681_int64, &
-3625522261068040523_int64, -3688972217741992772_int64,
-3749474917563780918_int64, &
-3807206277531066033_int64, -3862327722496832777_int64,
-3914987649156774371_int64, &
-3965322714631868789_int64, -4013458973776904711_int64,
-4059512885612775571_int64, &
-4103592206186240140_int64, -4145796782586126309_int64,
-4186219260694351160_int64, &
-4224945717447272663_int64, -4262056226866286506_int64,
-4297625367836515404_int64, &
-4331722680528539029_int64, -4364413077437474043_int64,
-4395757214229410182_int64, &
-4425811824915126951_int64, -4454630025296931623_int64,
-4482261588141301290_int64, &
-4508753193105274668_int64, -4534148654077814519_int64,
-4558489126279958535_int64, &
-4581813295192218010_int64, -4604157549138257917_int64,
-4625556137145252094_int64, &
-4646041313519107008_int64, -4665643470413307024_int64,
-4684391259530330202_int64, &
-4702311703971758561_int64, -4719430301145093973_int64,
-4735771117539952483_int64, &
-4751356876102085678_int64, -4766209036859141945_int64,
-4780347871386006289_int64, &
-4793792531638886797_int64, -4806561113635134843_int64,
-4818670716409303206_int64, &
-4830137496634475108_int64, -4840976719260841080_int64,
-4851202804490340302_int64, &
-4860829371376465578_int64, -4869869278311660680_int64,
-4878334660640769131_int64, &
-4886236965617420889_int64, -4893586984900801361_int64,
-4900394884772701206_int64, &
-4906670234238888961_int64, -4912422031164499511_int64,
-4917658726580128817_int64, &
-4922388247283526639_int64, -4926618016851058129_int64,
-4930354975163349944_int64, &
-4933605596540647482_int64, -4936375906575298263_int64,
-4938671497741363402_int64, &
-4940497543854573923_int64, -4941858813449628344_int64,
-4942759682136115973_int64, &
-4943204143989096034_int64, -4943195822025520534_int64,
-4942737977813217760_int64, &
-4941833520255016417_int64, -4940485013586754412_int64,
-4938694684624350782_int64, &
-4936464429291796994_int64, -4933795818458819764_int64,
-4930690103114058905_int64, &
-4927148218896869823_int64, -4923170790008281939_int64,
-4918758132519204034_int64, &
-4913910257091649047_int64, -4908626871126539190_int64,
-4902907380349533220_int64, &
-4896750889844278395_int64, -4890156204540517421_int64,
-4883121829162564021_int64, &
-4875645967641788341_int64, -4867726521994914537_int64,
-4859361090668117144_int64, &
-4850546966345100146_int64, -4841281133215543008_int64,
-4831560263698491528_int64, &
-4821380714613448338_int64, -4810738522790068329_int64,
-4799629400105478223_int64, &
-4788048727936306618_int64, -4775991551010520594_int64,
-4763452570642106428_int64, &
-4750426137329493684_int64, -4736906242696391928_int64,
-4722886510751374910_int64, &
-4708360188440094804_int64, -4693320135461424682_int64,
-4677758813316095437_int64, &
-4661668273553497421_int64, -4645040145179239295_int64,
-4627865621182777734_int64, &
-4610135444140930865_int64, -4591839890849342850_int64,
-4572968755929952125_int64, &
-4553511334358204380_int64, -4533456402849113793_int64,
-4512792200036279803_int64, &
-4491506405372576101_int64, -4469586116675404269_int64,
-4447017826233103268_int64, &
-4423787395382280037_int64, -4399880027458422930_int64,
-4375280239014120273_int64, &
-4349971829190466088_int64, -4323937847117722365_int64,
-4297160557210942232_int64, &
-4269621402214952430_int64, -4241300963840747800_int64,
-4212178920821854968_int64, &
-4182234004204454263_int64, -4151443949668870748_int64,
-4119785446662303522_int64, &
-4087234084103185161_int64, -4053764292396157155_int64,
-4019349281473095944_int64, &
-3983960974549683762_int64, -3947569937258414679_int64,
-3910145301787349605_int64, &
-3871654685619035220_int64, -3832064104425386085_int64,
-3791337878631549422_int64, &
-3749438533114321402_int64, -3706326689447986810_int64,
-3661960950051856150_int64, &
-3616297773528530358_int64, -3569291340409183073_int64,
-3520893408440942549_int64, &
-3471053156460668043_int64, -3419717015797774549_int64,
-3366828488034801678_int64, &
-3312327947826463661_int64, -3256152429334017728_int64,
-3198235394669707121_int64, &
-3138506482563180856_int64, -3076891235255160882_int64,
-3013310801389728773_int64, &
-2947681612411377003_int64, -2879915029671676459_int64,
-2809916959107513838_int64, &
-2737587429961860778_int64, -2662820133571330167_int64,
-2585501917733382572_int64, &
-2505512231579379230_int64, -2422722515205210513_int64,
-2336995527534099024_int64, &
-2248184604988707062_int64, -2156132842510781916_int64,
-2060672187261021857_int64, &
-1961622433929369701_int64, -1858790108950103127_int64,
-1751967229002893790_int64, &
-1640929916937145353_int64, -1525436855617589068_int64,
-1405227557075248277_int64, &
-1280020420662655717_int64, -1149510549536592414_int64,
-1013367289578707083_int64, &
-871231448632098451_int64, -722712146453669790_int64,
-567383236774430108_int64, &
-404779231966951925_int64, -234390647591536485_int64,
-55658667960112217_int64, &
132030985907824249_int64, 329355128892814265_int64,
537061298001092428_int64, &
755977262693563850_int64, 987022116608035296_int64,
1231219266829423286_int64, &
1489711711346527014_int64, 1763780090187555756_int64,
2054864117341786919_int64, &
2364588157623778796_int64, 2694791916990489737_int64,
3047567482883486812_int64, &
3425304305830815533_int64, 3830744187097289433_int64,
4267048975685834645_int64, &
4737884547990024084_int64, 5247525842198996915_int64,
5800989391535350163_int64, &
6404202162993299938_int64, 7064218894258535062_int64,
7789505049452342962_int64, &
8590309807749433783_int64, 7643763810684500598_int64,
8891950541491446588_int64, &
5457384281016217099_int64, 9083704440929284705_int64,
7976211653914441081_int64, &
8178631350487105377_int64, 2821287825726750080_int64,
6322989683301725109_int64, &
4309503753387613243_int64, 4685170734960179824_int64,
8404845967535220334_int64, &
7330522972447578232_int64, 1960945799077012817_int64,
4742910674644906342_int64, &
-751799822533487403_int64, 7023456603741968565_int64,
3843116882594667183_int64, &
3927231442413912436_int64, -9223372036854775807_int64,
-9223372036854775807_int64, &
-9223372036854775807_int64
&
]
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/108651] Array Constructor with [type-spec:: fails to apply to all values, eg x = [integer(int64):: 1,2,3,4]
2023-02-03 0:23 [Bug fortran/108651] New: Array Constructor with [type-spec:: fails to apply to all values, eg x = [integer(int64):: 1,2,3,4] Boyce at engineer dot com
` (2 preceding siblings ...)
2023-02-03 16:11 ` Boyce at engineer dot com
@ 2023-02-03 16:51 ` kargl at gcc dot gnu.org
2023-02-03 18:44 ` anlauf at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: kargl at gcc dot gnu.org @ 2023-02-03 16:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108651
--- Comment #4 from kargl at gcc dot gnu.org ---
(In reply to Scott Boyce from comment #3)
> No its not correct because the
Yes, it is the correct behavior. Please see 18-007r1.pdf, p.57.
7.4.3.1 Integer type
...
Any integer value can be represented as a signed-int-literal-constant.
...
The optional kind type parameter following digit-string
specifies the kind type parameter of the integer constant;
if it does not appear, the constant is default integer.
8258803693257250632 has default integer kind when it is parsed.
8258803693257250632_int64 has the integer type of integer(int64).
Now check Sec. 7.8 "Construction of array values".
R773 ac-value is expr
or ac-implied-do
8258803693257250632 is an expr.
C7111 (R770) If type-spec specifies an intrinsic type, each
ac-value expression in the array-constructor shall be of
an intrinsic type that is in type conformance with a
variable of type type-spec as specified in Table 10.8.
8258803693257250632 meets the requirements of type conformance.
18-007r1.pdf, p. 89. If type-spec appears, it specifies the
declared type and type parameters of the array constructor.
Each ac-value expression in the array-constructor shall be
compatible with intrinsic assignment to a variable of this type
and type parameters. Each value is converted to the type and
type parameters of the array-constructor in accordance
with the rules of intrinsic assignment (10.2.1.3).
Now, read that last sentence again, and then go read 10.2.1.3.
8258803693257250632 is treated as the right-hand-side of an
intrinsic assignment such as
integer(int64) x
x = 8258803693257250632
This won't work because mathematically 8258803693257250632
exceeds huge(1).
You have shown the correct way to do the array constructor,
and in that case the type-spec within the constructor is
redundant.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/108651] Array Constructor with [type-spec:: fails to apply to all values, eg x = [integer(int64):: 1,2,3,4]
2023-02-03 0:23 [Bug fortran/108651] New: Array Constructor with [type-spec:: fails to apply to all values, eg x = [integer(int64):: 1,2,3,4] Boyce at engineer dot com
` (3 preceding siblings ...)
2023-02-03 16:51 ` kargl at gcc dot gnu.org
@ 2023-02-03 18:44 ` anlauf at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-02-03 18:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108651
anlauf at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|FIXED |INVALID
--- Comment #5 from anlauf at gcc dot gnu.org ---
(In reply to kargl from comment #2)
> 5 | INTEGER(INT64), dimension(2), parameter:: arr1 = [integer(int64)::
> -3300711175878204139, 8258803693257250632]
> |
> 1
> Error: Integer too big for its kind at (1). This check can be disabled with
> the option '-fno-range-check'
>
> This is the correct behavior. -3300711175878204139 and 8258803693257250632
> are default integer kind, which is 32 bit and both numbers are outside the
> range of [-huge(1)-1:huge(1)].
Indeed, and this is confirmed by other compilers, which either give an
error (e.g. Nvidia) or at least a warning (Intel) in standard conformance
mode.
This PR should have been closed as invalid.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-02-03 18:44 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-03 0:23 [Bug fortran/108651] New: Array Constructor with [type-spec:: fails to apply to all values, eg x = [integer(int64):: 1,2,3,4] Boyce at engineer dot com
2023-02-03 7:18 ` [Bug fortran/108651] " kargl at gcc dot gnu.org
2023-02-03 7:33 ` kargl at gcc dot gnu.org
2023-02-03 16:11 ` Boyce at engineer dot com
2023-02-03 16:51 ` kargl at gcc dot gnu.org
2023-02-03 18:44 ` anlauf at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).