-
Notifications
You must be signed in to change notification settings - Fork 3
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
Build failure with GCC 14 (initialization from incompatible pointer type) #41
Comments
aclemons
added a commit
that referenced
this issue
Dec 11, 2024
We have some compile issues on 24.04. The open issue #41 is tracking this. We'll enable 24.04 when we commit the fix for that issue.
aclemons
added a commit
that referenced
this issue
Dec 12, 2024
These should take a pointer to a JNIEnv. These were introduced in b178aa0 to replace: ```c static char* utf2ucs(const char *utf8, char *ucs, size_t n); static char* ucs2utf(const char *ucs, char *utf8, size_t n); ``` They were added as: ```c static char* fromjstring(const JNIEnv *env, jstring value); static jstring tojstring(const JNIEnv *env, const char* value); ``` In this case however, we actually just wanted to declare these as a constant pointer not a pointer to a constant. Newer gcc versions complain with: ``` org_gnu_readline_Readline.c: In function ‘fromjstring’: org_gnu_readline_Readline.c:780:54: warning: passing argument 1 of ‘((const struct JNINativeInterface_ *)*env)->GetObjectClass’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] 780 | const jclass jstringClass = (*env)->GetObjectClass(env, value); | ^~~ org_gnu_readline_Readline.c:780:54: note: expected ‘const struct JNINativeInterface_ **’ but argument is of type ‘const struct JNINativeInterface_ * const*’ org_gnu_readline_Readline.c:781:58: warning: passing argument 1 of ‘((const struct JNINativeInterface_ *)*env)->GetMethodID’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] 781 | const jmethodID getBytesMethodId = (*env)->GetMethodID(env, jstringClass, "getBytes", "()[B"); | ^~~ org_gnu_readline_Readline.c:781:58: note: expected ‘const struct JNINativeInterface_ **’ but argument is of type ‘const struct JNINativeInterface_ * const*’ org_gnu_readline_Readline.c:783:74: warning: passing argument 1 of ‘((const struct JNINativeInterface_ *)*env)->CallObjectMethod’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] 783 | const jbyteArray jstringJBytes = (jbyteArray) (*env)->CallObjectMethod(env, value, getBytesMethodId); | ^~~ ``` Newer clang versions complain with: ``` org_gnu_readline_Readline.c:780:54: warning: passing 'const JNIEnv *' (aka 'const struct JNINativeInterface_ *const *') to parameter of type 'JNIEnv *' (aka 'const struct JNINativeInterface_ **') discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers] 780 | const jclass jstringClass = (*env)->GetObjectClass(env, value); | ^~~ org_gnu_readline_Readline.c:781:58: warning: passing 'const JNIEnv *' (aka 'const struct JNINativeInterface_ *const *') to parameter of type 'JNIEnv *' (aka 'const struct JNINativeInterface_ **') discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers] 781 | const jmethodID getBytesMethodId = (*env)->GetMethodID(env, jstringClass, "getBytes", "()[B"); | ^~~ org_gnu_readline_Readline.c:783:74: warning: passing 'const JNIEnv *' (aka 'const struct JNINativeInterface_ *const *') to parameter of type 'JNIEnv *' (aka 'const struct JNINativeInterface_ **') discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers] 783 | const jbyteArray jstringJBytes = (jbyteArray) (*env)->CallObjectMethod(env, value, getBytesMethodId); | ^~~ ``` Related to #41
aclemons
added a commit
that referenced
this issue
Dec 12, 2024
It returns a poineter to a jbyte, but it was incorrectly declared as a pointer to a const jbyte. The warning here is now resolved. Related to #41.
aclemons
added a commit
that referenced
this issue
Dec 12, 2024
Newer compilers error on this. They should do that - the code is incorrect - we are putting const char** values into this global array. If someone uses setVarStringImpl to write to one of these, it will crash. This is however already mentioned in the documentation: https://github.com/aclemons/java-readline/blob/99fe57e6c3544be476187fb7c66a664e6326c3ea/src/native/org_gnu_readline_Readline.c#L63-L64 and they all had a comment in front indicating they were: ```c const `/* const */* ``` Basically we are relying on code using java-readline to not call the wrong thing. It has been this way for more than 20 years, so for now I will not change this and will simply cast away the compiler error. Related to #41
Thanks @ebourg. I have handled all of these apart from: org_gnu_readline_Readline.c:98:3: error: initialization of ‘int *’ from incompatible pointer type ‘long unsigned int *’ [-Wincompatible-pointer-types]
98 | &rl_readline_state,
| ^
org_gnu_readline_Readline.c:98:3: note: (near initialization for ‘globalIntegerInternals[2]’) this is from an ABI change introduced in readline 7.0 where I raised an issue to track that (#45), and I need to think about how I best want to do it. I guess it will also be a breaking change for anything using java-readline if I bubble up the type change to java-readline's interface too. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
Readline fails to build with GCC 14, we get the following error in Debian:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1075200
The text was updated successfully, but these errors were encountered: