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

[Bug c/52283] "error: case label does not reduce to an integer constant" for constant folded cast expr


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52283

--- Comment #6 from Manuel LÃpez-IbÃÃez <manu at gcc dot gnu.org> 2012-02-16 18:25:30 UTC ---
(In reply to comment #5)
> On Thu, 16 Feb 2012, manu at gcc dot gnu.org wrote:
> 
> > What is the problem with stripping the nops *before giving the error* and if it
> > still fails, give an error?
> 
> NOPs are used to represent an intermediate expression that folded to an 
> integer constant but is not an integer constant expression and cannot 
> appear in one, as well as to carry TREE_NO_WARNING.  So you need to be 
> careful about where you strip them to avoid making something into an 
> integer constant expression that should not be one; don't strip them too 
> early.

Is this folding actually necessary for anything beyond diagnostics? I thought
it was agreed that folding in the FEs was EVIL and we should stop doing it.

> I think it would be OK to have a c_fully_fold_no_nop (which removes any 
> TREE_NO_WARNING nop from the return from c_fully_fold) that is used in the 
> relevant places (set_init_index, do_case, check_bitfield_type_and_width, 
> build_enumerator at least) which have the pedwarn-if-pedantic logic for 
> things folding to an integer constant where an integer constant expression 
> is required.

I wouldn't be surprised if the compiler got noticeably faster by removing all
early folding and all the workarounds and hacks that come with it, and
replacing it by doing a temporary c_fully_fold at those specific places that
needed it (and throwing away the result and keeping the original code around).


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