Skip to content
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

Fix "assignment from incompatible pointer type" #295

Merged
merged 1 commit into from
Jan 10, 2019

Conversation

ericherman
Copy link
Contributor

@ericherman ericherman commented Jan 10, 2019

I encountered this warning from gcc 7.3.0 building on Ubuntu:

dbdimp.c: In function ‘mysql_st_prepare’:
dbdimp.c:3207:24: warning: assignment from incompatible pointer type [-Wincompatible-pointer-types]
bind->is_null= (_Bool*) &(fbind->is_null);

The MYSQL_BIND field is_null is of type my_bool, not _Bool.

The type my_bool is (usually) type-defined to be of a char type.

Regardless, the imp_sth_phb_t field is_null is of type char.

This commit removes the cast, which means that if we later discover that my_bool is defined to be of a type incompatible with the imp_sth_phb_t field is_null, it will break at compile-time.

I encountered this warning from gcc 7.3.0 building on Ubuntu:

dbdimp.c: In function ‘mysql_st_prepare’:
dbdimp.c:3207:24: warning: assignment from incompatible pointer type [-Wincompatible-pointer-types]
           bind->is_null=      (_Bool*) &(fbind->is_null);

The "MYSQL_BIND" field "is_null" is of type "my_bool", not "_Bool".

The type "my_bool" is (usually) type-defined to be of a "char" type.

Regardless, the "imp_sth_phb_t" field "is_null" is of type "char".

This commit removes the cast, which means that if we later discover
that "my_bool" is defined to be of a type incompatible with the
"imp_sth_phb_t" field "is_null", it will break at compile-time.
@dveeden dveeden merged commit 3620fe0 into perl5-dbi:master Jan 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants