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]

[C++/preprocessor Patch] PR c++/53690


Hi,

this issue isn't a regression but it's getting a lot of attention and duplicates. Essentially, due to the lines at the very end of _cpp_valid_ucn:

  if (result == 0)
    result = 1;

  return result;
}

we can't possibly get the encoding of \U00000000 right in C++, that is zero, even after Jason's r152614 which added the following special case for C++ earlier in the function:

  else if ((result < 0xa0
        && !CPP_OPTION (pfile, cplusplus)
        && (result != 0x24 && result != 0x40 && result != 0x60))
       || (result & 0x80000000)
       || (result >= 0xD800 && result <= 0xDFFF))
    {
      cpp_error (pfile, CPP_DL_ERROR,
         "%.*s is not a valid universal character",
         (int) (str - base), base);
      result = 1;
    }

thus letting result == 0 thru until the very end of the function. Now, fixing the problem seems easy: just change the return type of the function to int, thus return zero for success; add a cppchar_t* parameter cp where *cp is computed exactly like the current return value *without* the final reset to one. Note that this is supposed to have *no* effects whatsoever outside C++ because currently, for all those languages, the final reset never triggers: in the second conditional above, a result == 0 triggers a cpp_error and result becomes == 1, thus the final conditional never sees result == 0.

Thus I'm finishing testing the below...

Thanks!
Paolo.

////////////////////////

Attachment: CL_53690
Description: Text document

Attachment: patch_53690
Description: Text document


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