carp icon indicating copy to clipboard operation
carp copied to clipboard

compilation error on ubuntu 14.04

Open khaledmdiab opened this issue 10 years ago • 29 comments

I am using my ubuntu 14.04 virtual machine to compile carp. The used compiler is gcc 4.8.2, I tried gcc 4.6 but got the same error:

cc -c -g3 -std=c99 -Wall -Werror -Wno-unused-variable -Wno-format-security -static  src/carp_instructions.c src/carp_lexer.c src/carp_machine.c src/carp_tokenizer.c src/lib/carp_stack.c src/lib/carp_ht.c
src/carp_instructions.c: In function ‘carp_instr_DBS’:
src/carp_instructions.c:144:15: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
   char *key = (char *) carp_vm_next(m);
               ^
src/carp_instructions.c: In function ‘carp_instr_DBG’:
src/carp_instructions.c:153:15: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
 char *key = (char *) carp_vm_next(m);
             ^
cc1: all warnings being treated as errors
make: *** [build] Error 1

khaledmdiab avatar Aug 14 '14 07:08 khaledmdiab

So this is an issue with trying to store pointers to the keys/strings in the program array. You are more than welcome to submit a pull request with a fix, but I am not sure what the best way to fix is.

On Thu, Aug 14, 2014 at 12:23 AM, Khaled Diab [email protected] wrote:

I am using my ubuntu 14.04 virtual machine to compile carp. The used compiler is gcc 4.8.2, I tried gcc 4.6 but got the same error:

cc -c -g3 -std=c99 -Wall -Werror -Wno-unused-variable -Wno-format-security -static src/carp_instructions.c src/carp_lexer.c src/carp_machine.c src/carp_tokenizer.c src/lib/carp_stack.c src/lib/carp_ht.c src/carp_instructions.c: In function ‘carp_instr_DBS’: src/carp_instructions.c:144:15: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast] char key = (char *) carp_vm_next(m); ^ src/carp_instructions.c: In function ‘carp_instr_DBG’: src/carp_instructions.c:153:15: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast] char *key = (char *) carp_vm_next(m); ^ cc1: all warnings being treated as errors make: ** [build] Error 1

— Reply to this email directly or view it on GitHub https://github.com/tekknolagi/carp/issues/19.

tekknolagi avatar Aug 14 '14 07:08 tekknolagi

(I don't see an issue since I guess clang realizes that going from 8 bytes to 1 byte in this case involves no truncation? Maybe?)

On Thu, Aug 14, 2014 at 12:29 AM, Maxwell Bernstein [email protected] wrote:

So this is an issue with trying to store pointers to the keys/strings in the program array. You are more than welcome to submit a pull request with a fix, but I am not sure what the best way to fix is.

On Thu, Aug 14, 2014 at 12:23 AM, Khaled Diab [email protected] wrote:

I am using my ubuntu 14.04 virtual machine to compile carp. The used compiler is gcc 4.8.2, I tried gcc 4.6 but got the same error:

cc -c -g3 -std=c99 -Wall -Werror -Wno-unused-variable -Wno-format-security -static src/carp_instructions.c src/carp_lexer.c src/carp_machine.c src/carp_tokenizer.c src/lib/carp_stack.c src/lib/carp_ht.c src/carp_instructions.c: In function ‘carp_instr_DBS’: src/carp_instructions.c:144:15: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast] char key = (char *) carp_vm_next(m); ^ src/carp_instructions.c: In function ‘carp_instr_DBG’: src/carp_instructions.c:153:15: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast] char *key = (char *) carp_vm_next(m); ^ cc1: all warnings being treated as errors make: ** [build] Error 1

— Reply to this email directly or view it on GitHub https://github.com/tekknolagi/carp/issues/19.

tekknolagi avatar Aug 14 '14 07:08 tekknolagi

By the way this should be a warning but I happen to have the flag that treats warnings as errors on.

A quick fix is simply to remove that flag in the makefile. On Aug 14, 2014 12:23 AM, "Khaled Diab" [email protected] wrote:

I am using my ubuntu 14.04 virtual machine to compile carp. The used compiler is gcc 4.8.2, I tried gcc 4.6 but got the same error:

cc -c -g3 -std=c99 -Wall -Werror -Wno-unused-variable -Wno-format-security -static src/carp_instructions.c src/carp_lexer.c src/carp_machine.c src/carp_tokenizer.c src/lib/carp_stack.c src/lib/carp_ht.c src/carp_instructions.c: In function ‘carp_instr_DBS’: src/carp_instructions.c:144:15: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast] char key = (char *) carp_vm_next(m); ^ src/carp_instructions.c: In function ‘carp_instr_DBG’: src/carp_instructions.c:153:15: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast] char *key = (char *) carp_vm_next(m); ^ cc1: all warnings being treated as errors make: ** [build] Error 1

— Reply to this email directly or view it on GitHub https://github.com/tekknolagi/carp/issues/19.

tekknolagi avatar Aug 14 '14 16:08 tekknolagi

Yes, I see the flag. But we may need a "safer" solution. I will see this one.

btw, what are the supported platforms and compilers? roughly speaking ..

khaledmdiab avatar Aug 14 '14 17:08 khaledmdiab

Do you have a safer solution? I would love to see it.

On Thu, Aug 14, 2014 at 9:56 AM, Maxwell Bernstein [email protected] wrote:

By the way this should be a warning but I happen to have the flag that treats warnings as errors on.

A quick fix is simply to remove that flag in the makefile. On Aug 14, 2014 12:23 AM, "Khaled Diab" [email protected] wrote:

I am using my ubuntu 14.04 virtual machine to compile carp. The used compiler is gcc 4.8.2, I tried gcc 4.6 but got the same error:

cc -c -g3 -std=c99 -Wall -Werror -Wno-unused-variable -Wno-format-security -static src/carp_instructions.c src/carp_lexer.c src/carp_machine.c src/carp_tokenizer.c src/lib/carp_stack.c src/lib/carp_ht.c src/carp_instructions.c: In function ‘carp_instr_DBS’: src/carp_instructions.c:144:15: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast] char key = (char *) carp_vm_next(m); ^ src/carp_instructions.c: In function ‘carp_instr_DBG’: src/carp_instructions.c:153:15: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast] char *key = (char *) carp_vm_next(m); ^ cc1: all warnings being treated as errors make: ** [build] Error 1

— Reply to this email directly or view it on GitHub https://github.com/tekknolagi/carp/issues/19.

tekknolagi avatar Aug 15 '14 02:08 tekknolagi

@khaledmdiab re: your errors — I am not seeing this on gcc 4.9 or clang. How odd!

tekknolagi avatar Aug 15 '14 06:08 tekknolagi

@tekknolagi I can test compiling on gcc 4.9, and see how it goes.

For the safer solution, I still don't know it, but hopefully get one soon. Rather than removing the flag, do you have suggestions?

khaledmdiab avatar Aug 18 '14 20:08 khaledmdiab

Sorry, wrong issue — thought I was fixing something else.

tekknolagi avatar Aug 24 '14 16:08 tekknolagi

@akkartik any ideas? Perhaps a separate string db array?

tekknolagi avatar Aug 24 '14 16:08 tekknolagi

Turns out I have a spare laptop with Trusty and gcc 4.8.2, but I see no errors on it. It's a 64-bit machine, and pointers have the same size as long ints. @khaledmdiab, can you share the output of uname -a?

@tekknolagi, there's an error in your comment above. You're going from a long int to a pointer, not to a char. So on an architecture where long ints are 8 bytes but pointers are 4, there would be truncation.

Anyway, here's my output:

$ uname -a
Linux thinkpad 3.13.0-32-generic #57-Ubuntu SMP Tue Jul 15 03:51:08 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

$ git log |head
commit 54f82711a0aa62602963f02b7e62654b87567566
Author: Max Bernstein <[email protected]>
Date:   Sun Aug 24 10:05:32 2014 -0700

    add << and >> operators on stack, fix string representation of 'and' in reverse_instr array

$ cc --version
cc (Ubuntu 4.8.2-19ubuntu1) 4.8.2

$ make
cc -c -g3 -std=c99 -Wall -Werror -Wno-unused-variable -Wno-format-security  src/carp_registers.c src/carp_instructions.c src/carp_lexer.c src/carp_machine.c src/carp_tokenizer.c src/lib/carp_stack.c src/lib/carp_ht.c
# no warnings
ar cr libcarp.a *.o
...

akkartik avatar Aug 24 '14 17:08 akkartik

Ah, correct. So there will be a warning on 32 bit systems?

On Sun, Aug 24, 2014 at 10:33 AM, Kartik Agaram [email protected] wrote:

Turns out I have a spare laptop with Trusty and gcc 4.8.2, but I see no errors on it. It's a 64-bit machine, and pointers have the same size as long ints. @khaledmdiab https://github.com/khaledmdiab, can you share the output of uname -a?

@tekknolagi https://github.com/tekknolagi, there's an error in your comment above. You're going from a long int to a pointer, not to a char. So on an architecture where long ints are 8 bytes but pointers are 4, there would be truncation.

Anyway, here's my output:

$ uname -a Linux thinkpad 3.13.0-32-generic #57-Ubuntu SMP Tue Jul 15 03:51:08 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

$ cc --version cc (Ubuntu 4.8.2-19ubuntu1) 4.8.2

$ make cc -c -g3 -std=c99 -Wall -Werror -Wno-unused-variable -Wno-format-security src/carp_registers.c src/carp_instructions.c src/carp_lexer.c src/carp_machine.c src/carp_tokenizer.c src/lib/carp_stack.c src/lib/carp_ht.c

no warnings

ar cr libcarp.a *.o ...

— Reply to this email directly or view it on GitHub https://github.com/tekknolagi/carp/issues/19#issuecomment-53200652.

tekknolagi avatar Aug 24 '14 17:08 tekknolagi

I don't have access to one, so I'm not sure. Were long ints 8 bytes on 32-bit machines?

akkartik avatar Aug 24 '14 17:08 akkartik

I'm unclear on what DBS and DBG do. I see them used in examples/c/data.c, but what is the expected result?

akkartik avatar Aug 24 '14 17:08 akkartik

They are/were (not sure if I want them) for storing variables.

On Sun, Aug 24, 2014 at 10:42 AM, Kartik Agaram [email protected] wrote:

I'm unclear on what DBS and DBG do. I see them used in examples/c/data.c, but what is the expected result?

— Reply to this email directly or view it on GitHub https://github.com/tekknolagi/carp/issues/19#issuecomment-53200936.

tekknolagi avatar Aug 24 '14 17:08 tekknolagi

Maybe rip them out (YAGNI) until you have a use case? :) Easy to bring back from history once you're sure what you want.

akkartik avatar Aug 24 '14 17:08 akkartik

Gone :) On Aug 24, 2014 10:45 AM, "Kartik Agaram" [email protected] wrote:

Maybe rip them out (YAGNI) until you have a use case? :) Easy to bring back from history once you're sure what you want.

— Reply to this email directly or view it on GitHub https://github.com/tekknolagi/carp/issues/19#issuecomment-53201071.

tekknolagi avatar Aug 24 '14 20:08 tekknolagi

@tekknolagi @akkartik it's a 32-bit vm ..

uname -a
Linux khaled-00 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:08:14 UTC 2014 i686 i686 i686 GNU/Linux

I tried it using both gcc 4.6.4 and 4.8.2

khaledmdiab avatar Aug 25 '14 06:08 khaledmdiab

Thanks!

akkartik avatar Aug 25 '14 06:08 akkartik

In any case, I have removed the problematic features (and I think pushed when I landed).

On Mon, Aug 25, 2014 at 2:15 AM, Kartik Agaram [email protected] wrote:

Thanks!

— Reply to this email directly or view it on GitHub https://github.com/tekknolagi/carp/issues/19#issuecomment-53230060.

tekknolagi avatar Aug 26 '14 01:08 tekknolagi

Whoops, now it's up.

On Mon, Aug 25, 2014 at 9:50 PM, Maxwell Bernstein [email protected] wrote:

In any case, I have removed the problematic features (and I think pushed when I landed).

On Mon, Aug 25, 2014 at 2:15 AM, Kartik Agaram [email protected] wrote:

Thanks!

— Reply to this email directly or view it on GitHub https://github.com/tekknolagi/carp/issues/19#issuecomment-53230060.

tekknolagi avatar Aug 26 '14 02:08 tekknolagi

it was successfully compiled. but fails in the "test" target. looks like "tests/libtap" directory is empty. is it normal? or I'm missing something.

khaledmdiab avatar Aug 26 '14 02:08 khaledmdiab

Looks like you missed the instructions in the README.md — check that for help.

On Mon, Aug 25, 2014 at 10:28 PM, Khaled Diab [email protected] wrote:

it was successfully compiled. but fails in the "test" target. looks like "tests/libtap" directory is empty. is it normal? or I'm missing something.

— Reply to this email directly or view it on GitHub https://github.com/tekknolagi/carp/issues/19#issuecomment-53367528.

tekknolagi avatar Aug 26 '14 02:08 tekknolagi

done .. I think we need to keep a complete list of platforms/operating systems/compilers at which carp supports.

khaledmdiab avatar Aug 26 '14 03:08 khaledmdiab

Good idea. What seems to be the issue, other than your 32 bit warning?

Perhaps submit a PR to the readme file in the style that already exists. On Aug 25, 2014 11:11 PM, "Khaled Diab" [email protected] wrote:

done .. I think we need to keep a complete list of platforms/operating systems/compilers at which carp supports.

— Reply to this email directly or view it on GitHub https://github.com/tekknolagi/carp/issues/19#issuecomment-53370341.

tekknolagi avatar Aug 26 '14 03:08 tekknolagi

I don't have additional warnings till now. but in future, who knows? :)

khaledmdiab avatar Aug 26 '14 03:08 khaledmdiab

I use ubuntu 14.04.1 64bit virtual machine to compile carp.but still have the problem ,

asd@ubuntu:~/Desktop/tekknolagi-carp-a93c5cf$ make cc -c -g3 -std=c99 -Wall -Werror -Wno-unused-variable -Wno-format-security src/carp_registers.c src/carp_instructions.c src/carp_lexer.c src/carp_machine.c src/carp_tokenizer.c src/lib/carp_stack.c src/lib/carp_ht.c ar cr libcarp.a .o cc -g3 -std=c99 -Wall -Werror -Wno-unused-variable -Wno-format-security src/carp.c libcarp.a -o carp.out find . -name ".o"
-o -name "_.dSYM"
| xargs rm -rf cd tests/libtap && make make[1]: Entering directory /home/asd/Desktop/tekknolagi-carp-a93c5cf/tests/libtap' make[1]: *_\* No targets specified and no makefile found. Stop. make[1]: Leaving directory /home/asd/Desktop/tekknolagi-carp-a93c5cf/tests/libtap' make: *** [libtap] Error 2

nikiyiyi avatar Aug 27 '14 02:08 nikiyiyi

Okay, so you appear not to be cloning the repository correctly; make sure to include the --recursive flags.

On Tue, Aug 26, 2014 at 10:08 PM, nikiyiyi [email protected] wrote:

I use ubuntu 14.04.1 64bit virtual machine to compile carp.but still have the problem ,

asd@ubuntu:~/Desktop/tekknolagi-carp-a93c5cf$ make cc -c -g3 -std=c99 -Wall -Werror -Wno-unused-variable -Wno-format-security src/carp_registers.c src/carp_instructions.c src/carp_lexer.c src/carp_machine.c src/carp_tokenizer.c src/lib/carp_stack.c src/lib/carp_ht.c ar cr libcarp.a

.o cc -g3 -std=c99 -Wall -Werror -Wno-unused-variable -Wno-format-security src/carp.c libcarp.a -o carp.out find . -name ".o"
-o -name "

_.dSYM" \ | xargs rm -rf cd tests/libtap && make make[1]: Entering directory /home/asd/Desktop/tekknolagi-carp-a93c5cf/tests/libtap' make[1]: *_\* No targets specified and no makefile found. Stop. make[1]: Leaving directory /home/asd/Desktop/tekknolagi-carp-a93c5cf/tests/libtap' make: *** [libtap] Error 2

— Reply to this email directly or view it on GitHub https://github.com/tekknolagi/carp/issues/19#issuecomment-53518646.

tekknolagi avatar Aug 27 '14 02:08 tekknolagi

Is this working now?

tekknolagi avatar Dec 04 '14 00:12 tekknolagi

Is this still valid in HEAD?

fredmorcos avatar Dec 04 '14 13:12 fredmorcos