Skip to content

Fix compile warnings (cygwin gcc) #44

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

Merged
merged 1 commit into from
Nov 24, 2021
Merged

Conversation

xtrnc
Copy link
Contributor

@xtrnc xtrnc commented Nov 24, 2021

Compiling with cygwin (gcc 10.2.0) on win10 fails because of "array
subscript has type 'char'" warnings. If isspace is called with a
negative char value it would invoke undefined behavior.

gcc -O3 -Wall -Werror -fpic -std=gnu99 -shared src/fzf.c -o build/libfzf.dll
In file included from src/fzf.c:4:
src/fzf.c: In function 'leading_whitespaces':
src/fzf.c:83:27: error: array subscript has type 'char' [-Werror=char-subscripts]
   83 |     if (!isspace(str->data[i])) {
      |                  ~~~~~~~~~^~~
src/fzf.c: In function 'trailing_whitespaces':
src/fzf.c:94:27: error: array subscript has type 'char' [-Werror=char-subscripts]
   94 |     if (!isspace(str->data[i])) {
      |                  ~~~~~~~~~^~~
src/fzf.c: In function '__prefix_match':
src/fzf.c:852:29: error: array subscript has type 'char' [-Werror=char-subscripts]
  852 |   if (!isspace(pattern->data[0])) {
      |                ~~~~~~~~~~~~~^~~
src/fzf.c: In function '__suffix_match':
src/fzf.c:894:49: error: array subscript has type 'char' [-Werror=char-subscripts]
  894 |   if (len_pattern == 0 || !isspace(pattern->data[len_pattern - 1])) {
      |                                    ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make: *** [Makefile:19: build/libfzf.dll] Error 1

Using the same version of gcc from msys2 mingw64 doesn't have this issue.

Compiling with cygwin (gcc 10.2.0) on win10 fails because of "array
subscript has type 'char'" warnings. If isspace is called with a
negative char value it would invoke undefined behavior.
@Conni2461
Copy link
Member

Had to check the specification but yeah you are right.

Thanks :)

@Conni2461 Conni2461 merged commit b8662b0 into nvim-telescope:main Nov 24, 2021
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