phillipstanleymarbell / Noisy-lang-compiler

Noisy language compiler
MIT License
17 stars 1 forks source link

Newton lexer error when compiled with clang-14 #613

Open janithpet opened 2 years ago

janithpet commented 2 years ago

Describe the bug After compiling using clang v14, newton produces the following error message when using newton-linux-EN:

newton-lexer.c:151:89: runtime error: implicit conversion from type 'int' of value -1 (32-bit, signed) to type 'unsigned long' changed the value to 18446744073709551615 (64-bit, unsigned)
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior newton-lexer.c:151:89 in 
newton-lexer.c:151:26: runtime error: implicit conversion from type '__ssize_t' (aka 'long') of value -1 (64-bit, signed) to type 'uint64_t' (aka 'unsigned long') changed the value to 18446744073709551615 (64-bit, unsigned)
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior newton-lexer.c:151:26 in

To Reproduce Steps to reproduce the behavior:

  1. Clone repo using git clone --recursive git@github.com:phillipstanleymarbell/Noisy-lang-compiler.git
  2. Create config.local in root directory, and submodules/libflex. config.local looks like:
    LIBFLEXPATH=<path-to-repo>/Noisy-lang-compiler/submodules/libflex
    CONFIGPATH=<path-to-repo>/home/janith/Noisy-lang-compiler/submodules/libflex
    OSTYPE=linux
    MACHTYPE=x86_64
  3. Change COMPILERVARIANT = gcc #clang to COMPILERVARIANT = clang in src/common/Makefile, src/newton/Makefile, and submodules/libflex/Makefile.
  4. run make in submodules/libflex.
  5. run make in src/newton.
  6. from src/newton, run newton-linux-EN <any newton file>.

Host OS (please complete the following information):

Local changes: Base

-COMPILERVARIANT = gcc #clang +COMPILERVARIANT = clang

LLVM_CONFIG?=llvm-config

diff --git a/submodules/libflex b/submodules/libflex --- a/submodules/libflex +++ b/submodules/libflex @@ -1 +1 @@ -Subproject commit d7207627830fc093e4259281b757bdd1305018f6 +Subproject commit d7207627830fc093e4259281b757bdd1305018f6-dirty


- Output of `git remote -v`.

origin git@github.com:phillipstanleymarbell/Noisy-lang-compiler.git (fetch) origin git@github.com:phillipstanleymarbell/Noisy-lang-compiler.git (push)


#### Local changes: libflex
- Output of `git diff`:

diff --git a/Makefile b/Makefile index 89849a2..4b7c4c9 100755 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@

make OSTYPE=android MACHTYPE=x86_64 COMPILERVARIANT= WFLAGS=

# include config.local -COMPILERVARIANT = gcc #clang +COMPILERVARIANT = clang include $(CONFIGPATH)/config.$(OSTYPE)-$(MACHTYPE).$(COMPILERVARIANT)

TARGET = libflex-$(OSTYPE).a


- Output of `git remote -v`:

origin git@github.com:phillipstanleymarbell/libflex.git (fetch) origin git@github.com:phillipstanleymarbell/libflex.git (push)

janithpet commented 2 years ago

This issue seems to be fixed by changing the version of clang to clang-11, and compiling using gcc.

On the system, I :

  1. ran sudo apt remove clang
  2. ran sudo apt autoremove
  3. ran sudo apt install clang-11
  4. created symbolic links to clang and clang++ from clang-11 and clang++-11 in /usr/bin. The previous step installed the clang tools with the -11 suffix in /usr/bin.
  5. changed the compiler to COMPILEVARIANT = gcc in src/common/Makefile, src/newton/Makefile, and submodules/libflex/Makefile.
  6. reran make (after make clean) in submodules/libflex and src/newton, in that order.
KomaGR commented 2 years ago

This looks like an error that is already happening and is just not getting caught with clang-11. Did you try with clang-12 or clang-13 before clang-11?

janithpet commented 2 years ago

No I didn't, I jumped straight to clang-11.