Andrew Pinski <pins...@gmail.com> writes: > On Tue, Sep 14, 2010 at 11:47 AM, Uday P. Khedker <u...@cse.iitb.ac.in> wrote: >> Attached please find two dumps t.c.032t.mergephi1 and t.c.033t.cddce1. >> The assignment is present in the former while it disappears in the >> latter. The latter dump is the output of the dead code elimination >> pass pass_cd_dce. So this is indeed an instance of dead code elimination. >> >> But may be you are right, what facilitate dead code elimination >> be based on modification of read-only data. However, if that is >> the case, I wonder what is the reason why change happens when s is >> an array... > > What is being done is correct really. Since the string has the type > of const char[]. Since you have an explicit cast to get rid of the > const qualifer, we don't warn. I don't see a bug here at all really. > You are invoking an undefined behavior, GCC keep the assignment around > or get rid of it.
I agree that this is technically correct but I still think it is a bad choice. Fortunately it does seem to work as I want in mainline. Ian