https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124025
Bug ID: 124025
Summary: bogus "potentially unsynchronized barrier" warning
Product: gcc
Version: 15.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: ada
Assignee: unassigned at gcc dot gnu.org
Reporter: liam at liampwll dot com
CC: dkm at gcc dot gnu.org
Target Milestone: ---
Sometimes a bogus "potentially unsynchronized barrier" warning can be generated
when controlled transient objects, and likely in other cases. The issue here is
that Is_Global_Entity, which generates the warning, only checks that the scope
of the variable being tested against is exactly equal to the scope of the
barrier function rather than being within it.
The issue in Is_Global_Entity has always been present but the below test case
only reveals it on or after commit g:48d7a599ecd141f7936deff6170dd5199edb2d98.
with Ada.Finalization;
procedure Example is
type T is new Ada.Finalization.Controlled with null record;
protected type Queue is
entry Get_Next_Line (Line : out String);
private
A : T;
end Queue;
protected body Queue is
entry Get_Next_Line (Line : out String)
when A /= (Ada.Finalization.Controlled with null record)
is
begin
null;
end Get_Next_Line;
end Queue;
begin
null;
end Example;
example.adb:15:19: warning: potentially unsynchronized barrier [enabled by
default]
example.adb:15:19: warning: "A123b" should be private component of type
[enabled by default]