This is the mail archive of the gcc-patches@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]

Re: fold casted const variables


> On Sun, 16 Feb 2003, Jan Hubicka wrote:
> 
> > Hi,
> > the following testcase does not get current simplified as it should.
> > 
> > Bootstrapped/regtested on i386.  OK?
> > Honza
> > void link_error (void);
> > const double one=1.0;
> > t()
> > {
> > 	if ((int)one != 1)
> > 		link_error ();
> > }
> > Sun Feb 16 17:34:30 CET 2003  Jan Hubicka  <jh@suse.cz>
> > 
> > 	* c-typeck.c (build_c_cast):  Fold constant variables into
> > 	initial values.
> 
> You have made sure that this doesn't cause anything to be counted as an
> integer constant expression that shouldn't be and isn't currently?  (See
> c9?-const-expr-3.c and add testcases (to both files) for casting a double
> 0.0 to int.  (int)0.0 is constant (pass), (int)(0.0+0.0), (int)+0.0,
> (int)(double)0.0 aren't (probably fail), (int)zero where const double zero
> = 0.0; shouldn't be constant either.)
Hmm, originally I've placed the conversion to the front of the function
and it caused c9?-const-expr-3.c to fail, so I've moved it to later
place.  I think it apears after all warnings and errors are output, so
it should work.  c9?-const-expr-3.c already contains testcases for
casted const variables I am shooting for.  (it is not only double and
int combination, the code works for int/short case as well that is
covered by the test)
In what testcase do you expect this to fail?

Honza
> 
> -- 
> Joseph S. Myers
> jsm28@cam.ac.uk


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