public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rosen at adalog dot fr" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug ada/95664] generic instantiation fails to detect abstract equality, builds with gcc-9 and fails to link with gcc-10
Date: Sun, 14 Jun 2020 05:21:30 +0000	[thread overview]
Message-ID: <bug-95664-4-POEabWHTK5@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-95664-4@http.gcc.gnu.org/bugzilla/>

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

Jean-Pierre Rosen <rosen at adalog dot fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rosen at adalog dot fr

--- Comment #2 from Jean-Pierre Rosen <rosen at adalog dot fr> ---
This is fixed in the development version of AdaControl.

Patch:
-   package Declarations_Store is new Scope_Manager.Scoped_Store
(Asis.Declaration);
+   package Declarations_Store is new Scope_Manager.Scoped_Store
(Asis.Declaration,
+                                                                
Equivalent_Keys => Asis.Elements.Is_Equal);


There is a hole in the language about this case. I reported to AdaCore, and
here is Tucker Taft's response:

   After looking through the RM, it seems that the use of an abstract "=" in
this context is not directly covered, but the closest thing is the rule about
what happens when you wrap a type with an abstract "=" into a record or array
type.  The abstract "=" raises Program_Error if it is ever invoked.  See RM
4.5.2 (24.1/3):

24.1/3
  {AI05-0123-1} If the primitive equals operator for an untagged record type is
abstract, then Program_Error is raised at the point of any (implicit) call to
that abstract subprogram. 

24.f/3
Reason: An explicit call to an abstract subprogram is illegal. This rule is
needed in order to define the effect of an implicit call such as a call that is
part of the predefined equality operation for an enclosing composite type that
has a component of an untagged record type that has an abstract primitive
equals operator. For tagged types, an abstract primitive equals operator is
only allowed for an abstract type, and abstract types cannot be components, so
this case does not occur. 

So my sense is that this should *not* be a compile-time error, but rather raise
Program_Error if the "=" operator of the formal type is invoked.  We also
should write up an AI to at least clarify this particular case.

We could try to make this illegal in the generic spec, but clearly we cannot
make it illegal in the generic body, because of contract issues.  But I think
the same argument applies here, namely that there is no need to disallow this
instantiation, unless "=" is actually used, which argues for raising
Program_Error rather than making it illegal.

  parent reply	other threads:[~2020-06-14  5:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-13 13:42 [Bug ada/95664] New: " nicolas at debian dot org
2020-06-13 16:01 ` [Bug ada/95664] " ludovic@ludovic-brenta.org
2020-06-14  5:21 ` rosen at adalog dot fr [this message]
2020-06-29 11:10 ` [Bug ada/95664] link failure with abstract equality operator ebotcazou at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-95664-4-POEabWHTK5@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).