comp.lang.ada
 help / color / mirror / Atom feed
* Strange GNAT compiler warning
@ 2011-12-28 14:37 Jan Andres
  2011-12-28 16:49 ` Georg Bauhaus
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Andres @ 2011-12-28 14:37 UTC (permalink / raw)


Consider the following package:

package Strange_Warning is
    type Foo is limited interface;
    type Bar is new Foo with null record;
end Strange_Warning;

When I compile this package with GNAT GPL 2011 and use the "-Wall"
option, I get the following warnings:

strange_warning.ads: In function 'Strange_Warning':
strange_warning.ads:3:14: warning: 'F' is used uninitialized in this function
strange_warning.ads: In function 'Strange_Warning':
strange_warning.ads:3:14: warning: 'C' is used uninitialized in this function
strange_warning.ads:3:14: warning: 'F' is used uninitialized in this function
strange_warning.ads: In function 'Strange_Warning':
strange_warning.ads:3:14: warning: 'C' is used uninitialized in this function
strange_warning.ads:3:14: warning: 'F' is used uninitialized in this function

The same thing shows up with the GNAT compiler that comes bundled with
recent versions of gcc, e.g. in 4.6.2. It's seemingly related to the
"limited" keyword in the definition of the interface. If that keyword
is removed, the warnings go away.

These warnings look bogus to me; clearly there is nothing named C or F
in the above code, so this must be something internal to the compiler.

Is it a bug in the compiler or run-time? Has anyone seen this before and
knows a solution or workaround?

Thanks,
Jan



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

* Re: Strange GNAT compiler warning
  2011-12-28 14:37 Strange GNAT compiler warning Jan Andres
@ 2011-12-28 16:49 ` Georg Bauhaus
  2011-12-28 17:47   ` Jan Andres
  0 siblings, 1 reply; 3+ messages in thread
From: Georg Bauhaus @ 2011-12-28 16:49 UTC (permalink / raw)


On 28.12.11 15:37, Jan Andres wrote:
> package Strange_Warning is
>     type Foo is limited interface;
>     type Bar is new Foo with null record;
> end Strange_Warning;

-Wall is a GCC option made for front ends to languages
other than Ada, in GCC.

Use -gnatwa instead.

Guessing, though, there are occurrences of F and C in
what GNAT generates as sources from the internal tree,
with -gnatdg.

F and C are out mode parameters that seem to be related to
primitive operations.  As said, just a wild guess.





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

* Re: Strange GNAT compiler warning
  2011-12-28 16:49 ` Georg Bauhaus
@ 2011-12-28 17:47   ` Jan Andres
  0 siblings, 0 replies; 3+ messages in thread
From: Jan Andres @ 2011-12-28 17:47 UTC (permalink / raw)


On 2011-12-28, Georg Bauhaus <rm.dash-bauhaus@futureapps.de> wrote:
> On 28.12.11 15:37, Jan Andres wrote:
>> package Strange_Warning is
>>     type Foo is limited interface;
>>     type Bar is new Foo with null record;
>> end Strange_Warning;
>
> -Wall is a GCC option made for front ends to languages
> other than Ada, in GCC.
>
> Use -gnatwa instead.

A-ha, thanks!

Actually, this is what the GNAT doc says about -Wall:

| `-Wall'
|      This switch enables most warnings from the `GCC' back end.  The
|      code generator detects a number of warning situations that are
|      missed by the `GNAT' front end, and this switch can be used to
|      activate them.  The use of this switch also sets the default front
|      end warning mode to `-gnatwa', that is, most front end warnings
|      activated as well.

So looks like it can make sense to use -Wall even with GNAT, but I
don't depend on it. I'll just go with -gnatwa for now.

-- 
Jan Andres <J@nAndr.es>



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

end of thread, other threads:[~2011-12-28 17:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-28 14:37 Strange GNAT compiler warning Jan Andres
2011-12-28 16:49 ` Georg Bauhaus
2011-12-28 17:47   ` Jan Andres

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox