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

Compile errors occured at Linux #20

Open
master-q opened this issue Nov 3, 2020 · 0 comments
Open

Compile errors occured at Linux #20

master-q opened this issue Nov 3, 2020 · 0 comments

Comments

@master-q
Copy link

master-q commented Nov 3, 2020

On my Debian GNU/Linux PC, this code causes following compile errors:

$ git clone git@github.com:microsoft/checkedc-clang.git
$ cd checkedc-parson/llvm/projects/checkedc-wrapper
$ git clone git@github.com:microsoft/checkedc.git
$ cd ../../../..
$ mkdir checkedc-clang-build
$ cd checkedc-clang-build
$ cmake -G Ninja -DLLVM_TARGETS_TO_BUILD="X86" -DLLVM_ENABLE_PROJECTS=clang ../checkedc-clang/llvm
$ ninja clang
$ ./bin/clang --version
clang version 9.0.0 (git@github.com:microsoft/checkedc-clang.git 07c6082412d73d07676014a78651af56d327acc8)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/kiwamu/src/checkedc/checkedc-clang-build/./bin
$ git clone git@github.com:microsoft/checkedc-parson.git
$ ls
checkedc-clang/  checkedc-clang-build/  checkedc-parson/  parson/
$ cd checkedc-parson
$ git diff
diff --git a/Makefile b/Makefile
index 3972877..7cb6519 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-CC = clang
+CC = ../checkedc-clang-build/bin/clang
 CFLAGS = -O0 -g -Wall -Wextra -std=c99 -pedantic-errors
 
 all: test
diff --git a/tests.c b/tests.c
index 76c1611..f067a92 100644
--- a/tests.c
+++ b/tests.c
@@ -68,10 +68,12 @@ static int tests_passed;
 static int tests_failed;
 
 int main() {
+    int i;
     /* Example functions from readme file:      */
     /* print_commits_info("torvalds", "linux"); */
     /* serialization_example(); */
     /* persistence_example(); */
+    for (i = 0; i < 1000; i++) {
     json_set_allocation_functions(counted_malloc, counted_free);
     test_suite_1();
     test_suite_2_no_comments();
@@ -88,6 +90,7 @@ int main() {
 
     printf("Tests failed: %d\n", tests_failed);
     printf("Tests passed: %d\n", tests_passed);
+    }
     return 0;
 }
$ make compile |& grep -A 6 error
../checkedc-clang-build/bin/clang -O0 -g -Wall -Wextra -std=c99 -pedantic-errors -o test tests.c parson.c
parson.c:78:29: error: static variable 'parson_malloc' has a type that uses a type variable bound in an enclosing scope (type is 'JSON_Malloc_Function' and type variable is 'T')
static JSON_Malloc_Function parson_malloc;
                            ^
./parson.h:63:24: note: type variable 'T' declared here
typedef _Itype_for_any(T) void * tmp_malloc_fun(size_t s) : byte_count(s) itype(_Array_ptr<T>);
                       ^
parson.c:79:27: error: static variable 'parson_free' has a type that uses a type variable bound in an enclosing scope (type is 'JSON_Free_Function' and type variable is 'T')
static JSON_Free_Function parson_free;
                          ^
./parson.h:64:24: note: type variable 'T' declared here
typedef _Itype_for_any(T) void tmp_free_fun(void * : byte_count(0) itype(_Array_ptr<T>));
                       ^
parson.c:292:35: warning: cannot prove argument meets declared bounds for 1st parameter [-Wcheck-bounds-decls-checked-scope]
--
44 warnings and 2 errors generated.
make: *** [Makefile:12: compile] Error 1

How to fix them?

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

No branches or pull requests

1 participant