This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Warning regression with COMPARE fixes


Jeff Sturm wrote:
> 
> On Mon, 19 Mar 2001, Mark Mitchell wrote:
> > My inclination would be to redo this warning at the tree level, in a
> > simpler, more predictable way -- but not before 3.0.  I would specify
> > the conditions under which the warning should appear in terms of the
> > user's source code -- not GCC's internal representation -- and then
> > implement that.  Probably, that means moving the warning to the tree
> > level.
> 
> FWIW, Java generates an error upon unitialized variables and must be
> precise in its detection. 

Precise, maybe -- in that the detection process is quite formally
defined and repeatable -- but not always right.  It is quite easy
to write code where initialization is guaranteed but the Java rules
don't see it.

int works(boolean b) {
  final int a;
  if (b) { a = 1; } else { a = 2; }
  return a;
}

int doesnotwork(boolean b) {
  final int a;
  if (b) { a = 1; }
  if (!b) { a = 2; }
  return a;
}

In the second example, a Java compiler must diagnose an error.
It might be that this formal predictability is preferred.  I don't
care either way.  The Java rules do at least make life easy for
compiler writers :)

-- James Dennett


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]