-
Notifications
You must be signed in to change notification settings - Fork 8k
Fix GH-20106: locale methods catering to stricter C++ rules. #20110
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
@nono303 would you be able to try this branch ? |
Hi @devnexen |
Can you give another try please ? |
🎉 compile without errors on a9a7858 |
ext/intl/locale/locale_methods.cpp
Outdated
const char *c_loc_name = const_cast<char *>(loc_name); | ||
add_array_entry( c_loc_name , return_value , const_cast<char *>(LOC_LANG_TAG)); | ||
add_array_entry( c_loc_name , return_value , const_cast<char *>(LOC_SCRIPT_TAG)); | ||
add_array_entry( c_loc_name , return_value , const_cast<char *>(LOC_REGION_TAG)); | ||
add_array_entry( c_loc_name , return_value , const_cast<char *>(LOC_VARIANT_TAG)); | ||
add_array_entry( c_loc_name , return_value , const_cast<char *>(LOC_PRIVATE_TAG)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None of these casts are necessary I think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ext\intl\locale\locale_methods.cpp(1144): error C2664: 'int add_array_entry(const char *,zval *,char *)' : impossible de convertir l'argument 3 de 'const char [9]' en 'char *'
ext\intl\locale\locale_methods.cpp(1144): note: La conversion d'un litteral de chaine perd le qualificateur const (voir /Zc:strictStrings)
ext\intl\locale\locale_methods.cpp(1056): note: voir la declaration de 'add_array_entry'
ext\intl\locale\locale_methods.cpp(1144): note: lors de la tentative de mise en correspondance de la liste des arguments '(char *, zval *, const char [9])'
ext\intl\locale\locale_methods.cpp(1145): error C2664: 'int add_array_entry(const char *,zval *,char *)' : impossible de convertir l'argument 3 de 'const char [7]' en 'char *'
ext\intl\locale\locale_methods.cpp(1145): note: La conversion d'un litteral de chaine perd le qualificateur const (voir /Zc:strictStrings)
ext\intl\locale\locale_methods.cpp(1056): note: voir la declaration de 'add_array_entry'
ext\intl\locale\locale_methods.cpp(1145): note: lors de la tentative de mise en correspondance de la liste des arguments '(char *, zval *, const char [7])'
ext\intl\locale\locale_methods.cpp(1146): error C2664: 'int add_array_entry(const char *,zval *,char *)' : impossible de convertir l'argument 3 de 'const char [7]' en 'char *'
ext\intl\locale\locale_methods.cpp(1146): note: La conversion d'un litteral de chaine perd le qualificateur const (voir /Zc:strictStrings)
ext\intl\locale\locale_methods.cpp(1056): note: voir la declaration de 'add_array_entry'
ext\intl\locale\locale_methods.cpp(1146): note: lors de la tentative de mise en correspondance de la liste des arguments '(char *, zval *, const char [7])'
ext\intl\locale\locale_methods.cpp(1147): error C2664: 'int add_array_entry(const char *,zval *,char *)' : impossible de convertir l'argument 3 de 'const char [8]' en 'char *'
ext\intl\locale\locale_methods.cpp(1147): note: La conversion d'un litteral de chaine perd le qualificateur const (voir /Zc:strictStrings)
ext\intl\locale\locale_methods.cpp(1056): note: voir la declaration de 'add_array_entry'
ext\intl\locale\locale_methods.cpp(1147): note: lors de la tentative de mise en correspondance de la liste des arguments '(char *, zval *, const char [8])'
ext\intl\locale\locale_methods.cpp(1148): error C2664: 'int add_array_entry(const char *,zval *,char *)' : impossible de convertir l'argument 3 de 'const char [8]' en 'char *'
ext\intl\locale\locale_methods.cpp(1148): note: La conversion d'un litteral de chaine perd le qualificateur const (voir /Zc:strictStrings)
ext\intl\locale\locale_methods.cpp(1056): note: voir la declaration de 'add_array_entry'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You misunderstood. Keep the signature change of add_array_entry
and then these casts should become unnecessary.
ext/intl/locale/locale_methods.cpp
Outdated
else { | ||
/* Call ICU variant */ | ||
variant = get_icu_value_internal( loc_name , LOC_VARIANT_TAG , &result ,0); | ||
variant = get_icu_value_internal( const_cast<char *>(loc_name) , LOC_VARIANT_TAG , &result ,0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get_icu_value_internal takes a const char *
as first argument, so this cast (and the ones below) are not necessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you mean ? char* loc_name = NULL;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can pass a char*
to a const char*
parameter and it works without a cast
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works, thanks
Hi @nono303 when you get the chance, can you confirm please ? thanks for your patience. |
Hi @devnexen, No problems ;) |
No description provided.