public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug ada/108610] New: Pure library procedures with limited parameters miscategorized
@ 2023-01-31  2:13 sbelmont700 at gmail dot com
  2023-05-11 16:01 ` [Bug ada/108610] pure " ebotcazou at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: sbelmont700 at gmail dot com @ 2023-01-31  2:13 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108610

            Bug ID: 108610
           Summary: Pure library procedures with limited parameters
                    miscategorized
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ada
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sbelmont700 at gmail dot com
                CC: dkm at gcc dot gnu.org
  Target Milestone: ---

The following (seemingly) legal code is rejected with a categorization error,
despite the elaboration pragma on B and apparently not violating any of the
requirements of 10.2.1:

package A is
  pragma Pure;  
  type T is limited null record;
end A;

with A;
procedure B (x : A.T) is
  pragma Pure;
begin
  null;
end B;

with B;
package C is
  pragma Pure;
end C;

$gnatmake -f c.ads
gcc -c c.ads
c.ads:1:06: error: cannot depend on "B" (wrong categorization)
c.ads:1:06: error: pure unit cannot depend on non-pure unit
gnatmake: "c.ads" compilation error


Presumably, gnat considers B as impure to implement the exception to the
permission in 10.2.1~18/3 (subprograms with limited parameters cannot have
their results reused), so this might also apply to parameters that take
System.Address, etc, or also in reverse (i.e. pure units incorrectly being
allowed to with non-pure units that the compiler has determined can be
optimized).

The version of GCC was built from the following commit:

commit 607f278a3546fe6b91a881318db85d7a0dfdacd9 (HEAD -> master, origin/trunk,
origin/master, origin/HEAD)
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Jan 24 00:17:23 2023 +0000

    Daily bump.

With the following configuration

$gnatmake -v
GNATMAKE 13.0.1 20230124 (experimental)
Copyright (C) 1992-2023, Free Software Foundation, Inc.
try "gnatmake --help" for more information.


$gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/home/sb/src/gcc/bin/libexec/gcc/x86_64-pc-linux-gnu/13.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../src/configure --prefix=/home/sb/src/gcc/bin
--enable-languages=c,c++,ada --disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 13.0.1 20230124 (experimental) (GCC) 


The following patch appears to mitigate the issue (within the
Get_Categorization subprogram, only consider the entity as pure if it has been
explicitly declared Pure) and passed the test suite, but i wouldn't presume to
imply its accuracy. 

diff --git a/gcc/ada/sem_cat.adb b/gcc/ada/sem_cat.adb
index 5398153a35d..ac276eb5443 100644
--- a/gcc/ada/sem_cat.adb
+++ b/gcc/ada/sem_cat.adb
@@ -160,7 +160,7 @@ package body Sem_Cat is

          --  Ignore Pure specification if set by pragma Pure_Function

-         if Is_Pure (E)
+         if Has_Pragma_Pure (E)
            and then not
             (Has_Pragma_Pure_Function (E) and not Has_Pragma_Pure (E))
          then


Thanks

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug ada/108610] pure library procedures with limited parameters miscategorized
  2023-01-31  2:13 [Bug ada/108610] New: Pure library procedures with limited parameters miscategorized sbelmont700 at gmail dot com
@ 2023-05-11 16:01 ` ebotcazou at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2023-05-11 16:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108610

Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2023-05-11
                 CC|                            |ebotcazou at gcc dot gnu.org
            Summary|Pure library procedures     |pure library procedures
                   |with limited parameters     |with limited parameters
                   |miscategorized              |miscategorized
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
Your analysis is correct, see Sem_Util.Check_Function_With_Address_Parameter.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-05-11 16:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-31  2:13 [Bug ada/108610] New: Pure library procedures with limited parameters miscategorized sbelmont700 at gmail dot com
2023-05-11 16:01 ` [Bug ada/108610] pure " ebotcazou 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).