This is the mail archive of the 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]
Other format: [Raw text]

Re: PR c/51712 -Wtype-limits should not trigger for types of implementation-defined signedness

On Tue, 1 May 2012, Manuel López-Ibáñez wrote:

> > What if the comparison is
> >
> > ?(unsigned) (expr_of_signed_enum_type) >= 0
> >
> > ? ?(With GCC, the enum will have a signed type if one of its values is
> > negative.) ?That seems worth a warning - the point of the patch as I
> > understand it is to avoid warning for
> What I understood from the PR is that we should never warn for enums.

I think the point is we shouldn't warn if the enum itself if part of the 
comparison - as opposed to the enum cast to some type whose signedness is 
not implementation-defined.  But at present it may be difficult to tell if 
there was an explicit cast of an unsigned enum to unsigned - but we can 
still detect the above case.

>  +/* Given an expression as a tree, return its original type.  Do this
> +   by stripping any conversion that generates no instruction but don't
> +   let the signedness change.  */

"generates no instruction" is not appropriate semantics for something 
related to diagnostics.  "any conversion that preserves the sign and 
precision"?  OK with that version.

Joseph S. Myers

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