public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug modula2/109952] New: Inconsistent HIGH values with 'ARRAY OF CHAR'
@ 2023-05-24 9:28 gaius at gcc dot gnu.org
2023-05-24 9:32 ` [Bug modula2/109952] " gaius at gcc dot gnu.org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: gaius at gcc dot gnu.org @ 2023-05-24 9:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109952
Bug ID: 109952
Summary: Inconsistent HIGH values with 'ARRAY OF CHAR'
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: modula2
Assignee: gaius at gcc dot gnu.org
Reporter: gaius at gcc dot gnu.org
Target Milestone: ---
As reported on the gm2 mailing list the behaviour of HIGH is inconsistent.
MODULE port_test8_gm2;
FROM IOChan IMPORT
ChanId;
FROM StdChans IMPORT
StdOutChan;
FROM Strings IMPORT
Length;
FROM TextIO IMPORT
WriteLn, WriteString;
FROM WholeIO IMPORT
WriteCard;
VAR
str_a: ARRAY[0..0] OF CHAR;
str_b: ARRAY[0..1] OF CHAR;
str_c: ARRAY[0..2] OF CHAR;
PROCEDURE ShowStringInfos(the_str: ARRAY OF CHAR);
VAR
cid_out: ChanId;
BEGIN (* PROCEDURE ShowStringInfos *)
cid_out:=StdOutChan();
WriteString(cid_out, 'Length(the_str): ');
WriteCard(cid_out, Length(the_str), 1);
WriteLn(cid_out);
WriteString(cid_out, 'HIGH(the_str): ');
WriteCard(cid_out, HIGH(the_str), 1);
WriteLn(cid_out);
WriteString(cid_out, 'the_str: ');
WriteString(cid_out, the_str);
WriteLn(cid_out);
WriteLn(cid_out);
END ShowStringInfos;
BEGIN (* MODULE port_test8_gm2 *)
ShowStringInfos('1');
ShowStringInfos('12');
ShowStringInfos('123');
str_a:='a';
ShowStringInfos(str_a);
str_b:='ab';
ShowStringInfos(str_b);
str_c:='abc';
ShowStringInfos(str_c);
str_c:='d';
ShowStringInfos(str_c);
END port_test8_gm2.
ShowStringInfos just prints out the Length, the HIGH value and the
string proper which is passed to the PROCEDURE. When using literals
'1', '12' and '123' the HIGH values are 0, 2 and 3.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug modula2/109952] Inconsistent HIGH values with 'ARRAY OF CHAR'
2023-05-24 9:28 [Bug modula2/109952] New: Inconsistent HIGH values with 'ARRAY OF CHAR' gaius at gcc dot gnu.org
@ 2023-05-24 9:32 ` gaius at gcc dot gnu.org
2023-05-24 10:16 ` cvs-commit at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: gaius at gcc dot gnu.org @ 2023-05-24 9:32 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109952
Gaius Mulley <gaius at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2023-05-24
Status|UNCONFIRMED |ASSIGNED
Ever confirmed|0 |1
--- Comment #1 from Gaius Mulley <gaius at gcc dot gnu.org> ---
Confirmed - interestingly the standard is silent on nul termination of constant
string literals passed as an actual parameter to ARRAY OF CHAR. But the
behaviour is certainly inconsistent and should be fixed.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug modula2/109952] Inconsistent HIGH values with 'ARRAY OF CHAR'
2023-05-24 9:28 [Bug modula2/109952] New: Inconsistent HIGH values with 'ARRAY OF CHAR' gaius at gcc dot gnu.org
2023-05-24 9:32 ` [Bug modula2/109952] " gaius at gcc dot gnu.org
@ 2023-05-24 10:16 ` cvs-commit at gcc dot gnu.org
2023-05-24 10:20 ` gaius at gcc dot gnu.org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-05-24 10:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109952
--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Gaius Mulley <gaius@gcc.gnu.org>:
https://gcc.gnu.org/g:b4df098647b687ca4e43952ec4a198b2816732ba
commit r14-1158-gb4df098647b687ca4e43952ec4a198b2816732ba
Author: Gaius Mulley <gaiusmod2@gmail.com>
Date: Wed May 24 11:14:07 2023 +0100
PR modula2/109952 Inconsistent HIGH values with 'ARRAY OF CHAR'
This patch fixes the case when a single character constant literal is
passed as a string actual parameter to an ARRAY OF CHAR formal parameter.
To be consistent a single character is promoted to a string and nul
terminated (and its high value is 1). Previously a single character
string would not be nul terminated and the high value was 0.
The documentation now includes a section describing the expected behavior
and included in this patch is some regression test code matching the
table inside the documentation.
gcc/ChangeLog:
PR modula2/109952
* doc/gm2.texi (High procedure function): New node.
(Using): New menu entry for High procedure function.
gcc/m2/ChangeLog:
PR modula2/109952
* Make-maintainer.in: Change header to include emacs file mode.
* gm2-compiler/M2GenGCC.mod (BuildHighFromChar): Check whether
operand is a constant string and is nul terminated then return one.
* gm2-compiler/PCSymBuild.mod (WalkFunction): Add default return
TRUE. Static analysis missing return path fix.
* gm2-libs/IO.mod (Init): Rewrite to help static analysis.
* target-independent/m2/gm2-libs.texi: Rebuild.
gcc/testsuite/ChangeLog:
PR modula2/109952
* gm2/pim/run/pass/hightests.mod: New test.
Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug modula2/109952] Inconsistent HIGH values with 'ARRAY OF CHAR'
2023-05-24 9:28 [Bug modula2/109952] New: Inconsistent HIGH values with 'ARRAY OF CHAR' gaius at gcc dot gnu.org
2023-05-24 9:32 ` [Bug modula2/109952] " gaius at gcc dot gnu.org
2023-05-24 10:16 ` cvs-commit at gcc dot gnu.org
@ 2023-05-24 10:20 ` gaius at gcc dot gnu.org
2023-06-12 11:25 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: gaius at gcc dot gnu.org @ 2023-05-24 10:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109952
Gaius Mulley <gaius at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
--- Comment #3 from Gaius Mulley <gaius at gcc dot gnu.org> ---
Closing as patch has been applied.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug modula2/109952] Inconsistent HIGH values with 'ARRAY OF CHAR'
2023-05-24 9:28 [Bug modula2/109952] New: Inconsistent HIGH values with 'ARRAY OF CHAR' gaius at gcc dot gnu.org
` (2 preceding siblings ...)
2023-05-24 10:20 ` gaius at gcc dot gnu.org
@ 2023-06-12 11:25 ` cvs-commit at gcc dot gnu.org
2023-07-29 3:14 ` cvs-commit at gcc dot gnu.org
2023-07-29 16:34 ` cvs-commit at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-06-12 11:25 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109952
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Eric Botcazou <ebotcazou@gcc.gnu.org>:
https://gcc.gnu.org/g:e8d41e031b9f52601249ec7e4c4215b851cc8ffe
commit r14-1710-ge8d41e031b9f52601249ec7e4c4215b851cc8ffe
Author: Eric Botcazou <ebotcazou@adacore.com>
Date: Mon Jun 12 11:34:38 2023 +0200
Fix oversight in latest change
gcc/
PR modula2/109952
* doc/gm2.texi (Standard procedures): Fix Next link.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug modula2/109952] Inconsistent HIGH values with 'ARRAY OF CHAR'
2023-05-24 9:28 [Bug modula2/109952] New: Inconsistent HIGH values with 'ARRAY OF CHAR' gaius at gcc dot gnu.org
` (3 preceding siblings ...)
2023-06-12 11:25 ` cvs-commit at gcc dot gnu.org
@ 2023-07-29 3:14 ` cvs-commit at gcc dot gnu.org
2023-07-29 16:34 ` cvs-commit at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-07-29 3:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109952
--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Gaius Mulley
<gaius@gcc.gnu.org>:
https://gcc.gnu.org/g:6ae50730003862aee81ad6c53e4c1a96ed1ee36e
commit r13-7640-g6ae50730003862aee81ad6c53e4c1a96ed1ee36e
Author: Gaius Mulley <gaiusmod2@gmail.com>
Date: Sat Jul 29 04:13:34 2023 +0100
PR modula2/109952 Inconsistent HIGH values with 'ARRAY OF CHAR'
This patch fixes the case when a single character constant literal is
passed as a string actual parameter to an ARRAY OF CHAR formal parameter.
To be consistent a single character is promoted to a string and nul
terminated (and its high value is 1). Previously a single character
string would not be nul terminated and the high value was 0.
The documentation now includes a section describing the expected behavior
and included in this patch is some regression test code matching the
table inside the documentation.
gcc/ChangeLog:
PR modula2/109952
* doc/gm2.texi (High procedure function): New node.
(Using): New menu entry for High procedure function.
gcc/m2/ChangeLog:
PR modula2/109952
* Make-maintainer.in: Change header to include emacs file mode.
* gm2-compiler/M2GenGCC.mod (BuildHighFromChar): Check whether
operand is a constant string and is nul terminated then return one.
* gm2-compiler/PCSymBuild.mod (WalkFunction): Add default return
TRUE. Static analysis missing return path fix.
* gm2-libs/IO.mod (Init): Rewrite to help static analysis.
* target-independent/m2/gm2-libs.texi: Rebuild.
gcc/testsuite/ChangeLog:
PR modula2/109952
* gm2/pim/run/pass/hightests.mod: New test.
(cherry picked from commit b4df098647b687ca4e43952ec4a198b2816732ba)
Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug modula2/109952] Inconsistent HIGH values with 'ARRAY OF CHAR'
2023-05-24 9:28 [Bug modula2/109952] New: Inconsistent HIGH values with 'ARRAY OF CHAR' gaius at gcc dot gnu.org
` (4 preceding siblings ...)
2023-07-29 3:14 ` cvs-commit at gcc dot gnu.org
@ 2023-07-29 16:34 ` cvs-commit at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-07-29 16:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109952
--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Gaius Mulley
<gaius@gcc.gnu.org>:
https://gcc.gnu.org/g:b555f824d6b6f2ab759f57098a7b4b3b47470c64
commit r13-7645-gb555f824d6b6f2ab759f57098a7b4b3b47470c64
Author: Gaius Mulley <gaiusmod2@gmail.com>
Date: Sat Jul 29 17:33:28 2023 +0100
PR modula2/109952 Fix oversight in latest change
gcc/
PR modula2/109952
* doc/gm2.texi (Standard procedures): Fix Next link.
(cherry picked from commit e8d41e031b9f52601249ec7e4c4215b851cc8ffe)
Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-07-29 16:35 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-24 9:28 [Bug modula2/109952] New: Inconsistent HIGH values with 'ARRAY OF CHAR' gaius at gcc dot gnu.org
2023-05-24 9:32 ` [Bug modula2/109952] " gaius at gcc dot gnu.org
2023-05-24 10:16 ` cvs-commit at gcc dot gnu.org
2023-05-24 10:20 ` gaius at gcc dot gnu.org
2023-06-12 11:25 ` cvs-commit at gcc dot gnu.org
2023-07-29 3:14 ` cvs-commit at gcc dot gnu.org
2023-07-29 16:34 ` cvs-commit 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).