-
Notifications
You must be signed in to change notification settings - Fork 1.3k
String literals with zero bytes #2997
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This fixes:
Zero bytes now work end to end (at least for D testing isn't hooked up in the branch as currently pushed. Go isn't automatically tested but the generated Go wrapper looks good: They don't currently work for Guile, Lua, mzscheme, Ocaml, Octave, Perl, Python, Ruby, Scilab, Tcl. R doesn't seem to wrap these constants at all so it's hard to tell if they would be mishandled. I don't think I'm going to attempt to fix all the target languages - if I fix the generic machinery and establish which target languages work (and ensure there's test coverage for those which do) then the target language maintainers (or users who care) can fix target languages which can handle strings with zero bytes. I think we ought to have tests for such strings in other situations though. |
The fix for PHP breaks other cases (which I missed locally despite testing - I guess the C++11 tests didn't get run):
For PHP we need a way to emit different code for the case where the constant value is a string literal. One current quirk of SWIG doesn't help here - string literals should really have type |
Many of the target languages don't handle this currently. Those that don't support this in their strings never will, but others can probably be fixed (e.g. I've fixed this for SWIG/PHP so far). Fixes swig#2996
422856b
to
3f2dfd8
Compare
Rebased onto current master and added a draft CHANGES.current entry. Also:
Done.
Done. |
Python test failures with MSVC don't seem connected to my changes, but the last CI build of git master didn't trigger these:
|
The other relevant situation is default arguments, but actually there a string literal with a zero byte gets truncated in C++ anyway so there isn't anything we can usefully test, consider:
|
The CI failure seems to be due to an MSVC change so I'm going to ignore that and merge this. |
Improve handling of zero bytes in string literals
Many of the target languages don't handle this currently. Those
that don't support this in their strings never will, but others
can probably be fixed (e.g. I've fixed this for SWIG/PHP so far).
Fixes #2996