[PATCH] C front-end: fix PR c/34867 (valgrind error indication in testsuite from c-lex.c:996:c_lex_with_flags for gcc.dg/cpp/charconst.c)

Laurynas Biveinis laurynas.biveinis@gmail.com
Fri Jun 27 11:24:00 GMT 2008


2008/6/24 Joseph S. Myers <joseph@codesourcery.com>:
>> To set unsignedp value, lex_charconst calls cpp_interpret_charconst.
>> Here it quits early with an error, leaving unsignedp uninitialized.
>> Fixed by checking error code and initializing unsignedp.
>> Bootstrapped/regtested x86_64-unknown-linux-gnu. OK for trunk?
>
> 0 is not just an error return here, as far as I can tell it can also be a
> valid return value in a non-error case.  It just so happens that the value
> of unsignedp doesn't matter if the return is 0, because it's only used in
> "unsignedp || (cppchar_signed_t) result >= 0".  I think it would be better
> just to initialize unsignedp when declared (unconditionally), before
> calling cpp_interpret_charconst.

So there is no way to know if cpp_interpret_charconst failed? OK, here
is the updated patch, bootstrapped/regtested on
x86_64-unknown-linux-gnu, OK for trunk?

Thanks,
Laurynas

2008-06-27  Laurynas Biveinis  <laurynas.biveinis@gmail.com>

        PR c/34867
        * c-lex.c (lex_charconst):  Initialize unsignedp.

Index: gcc/c-lex.c
===================================================================
--- gcc/c-lex.c (revision 137083)
+++ gcc/c-lex.c (working copy)
@@ -977,7 +977,7 @@
   cppchar_t result;
   tree type, value;
   unsigned int chars_seen;
-  int unsignedp;
+  int unsignedp = 0;

   result = cpp_interpret_charconst (parse_in, token,
                                    &chars_seen, &unsignedp);


-- 
Laurynas



More information about the Gcc-patches mailing list