Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

error in Tokenizer.cpp:99 #51

Open
dribbroc opened this issue Jan 22, 2016 · 5 comments
Open

error in Tokenizer.cpp:99 #51

dribbroc opened this issue Jan 22, 2016 · 5 comments

Comments

@dribbroc
Copy link

Running flint++ from master (c04020e) on my own code results in

flint++: Tokenizer.cpp:99: std::string flint::{anonymous}::munchSingleLineComment(std::string&, size_t&): Assertion `i < pc.size()' failed.

Program received signal SIGABRT, Aborted.
0x00007ffff75390d5 in __GI_raise (sig=) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
64 ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0 0x00007ffff75390d5 in __GI_raise (sig=) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#1 0x00007ffff753c83b in __GI_abort () at abort.c:91
#2 0x00007ffff7531d9e in __assert_fail_base (fmt=, assertion=0x422b70 "i < pc.size()", file=0x4224ea "Tokenizer.cpp", line=, function=) at assert.c:94
#3 0x00007ffff7531e42 in __GI___assert_fail (assertion=0x422b70 "i < pc.size()", file=0x4224ea "Tokenizer.cpp", line=99,

function=0x423460 "std::string flint::{anonymous}::munchSingleLineComment(std::string&, size_t&)") at assert.c:103

#4 0x000000000041f7be in flint::tokenize(std::string const&, std::string const&, std::vector<flint::Token, std::allocatorflint::Token >&) ()
#5 0x0000000000413b2c in checkEntry(flint::ErrorReport&, std::string const&, unsigned int) ()
#6 0x00000000004140f6 in checkEntry(flint::ErrorReport&, std::string const&, unsigned int) ()
#7 0x00000000004140f6 in checkEntry(flint::ErrorReport&, std::string const&, unsigned int) ()
#8 0x0000000000402f7e in main ()

@alariq
Copy link

alariq commented Mar 15, 2016

AFAIK this happens when comment has length of 2, i.e. nothing goes after // I have a sample file to reproduce this issue. But this assert is commented in the source version, so I think binaries should be updated

@AaronDMarasco
Copy link

I couldn't replicate in my fork - added empty comments to the test suite - 8ffd893. Please provide minimal working example here or as a new ticket on mine.

@lengocthuong15
Copy link

lengocthuong15 commented Jan 19, 2021

I've got the same issue. In my case, there is a comment with // at the end of the file and there is no ending line.
Ex:
image
To fix the issue, I just need to add an extra line below the comment
image

@AaronDMarasco
Copy link

@lengocthuong15 please try my fork at https://github.com/AaronDMarasco/FlintPlusPlus - this fork has been untouched for about six years now. I've added RPM, DEB, Docker, etc too.

I have a file that specifically doesn't have a newline at the end (within a comment) as part of the test suite - https://github.com/AaronDMarasco/FlintPlusPlus/blob/master/flint/tests/Comments.cpp

Original:

❯ xxd Comments.cpp | tail
000001a0: 7369 7665 2e0a 2320 2f2f 2049 7427 7320  sive..# // It's 
000001b0: 6e6f 7420 616e 2075 6e74 6572 6d69 6e61  not an untermina
000001c0: 7465 6420 7374 7269 6e67 2e0a 2320 2f2f  ted string..# //
000001d0: 204e 6569 7468 6572 2069 7320 2274 6869   Neither is "thi
000001e0: 732e 0a0a 2f2f 2045 6d70 7479 2063 6f6d  s...// Empty com
000001f0: 6d65 6e74 3a0a 2f2f 0a2f 2a2a 2f0a 2f2f  ment:.//./**/.//
00000200: 2050 6172 7469 6375 6c61 726c 7920 6e61   Particularly na
00000210: 7374 7920 656d 7074 7920 636f 6d6d 656e  sty empty commen
00000220: 7420 7769 7468 206e 6f20 6e65 776c 696e  t with no newlin
00000230: 652c 206a 7573 7420 454f 463a 0a2f 2f    e, just EOF:.//

I tried to emulate your problem and it passed all checks:

❯ xxd Comments.cpp | tail
000001c0: 7465 6420 7374 7269 6e67 2e0a 2320 2f2f  ted string..# //
000001d0: 204e 6569 7468 6572 2069 7320 2274 6869   Neither is "thi
000001e0: 732e 0a0a 2f2f 2045 6d70 7479 2063 6f6d  s...// Empty com
000001f0: 6d65 6e74 3a0a 2f2f 0a2f 2a2a 2f0a 2f2f  ment:.//./**/.//
00000200: 2050 6172 7469 6375 6c61 726c 7920 6e61   Particularly na
00000210: 7374 7920 656d 7074 7920 636f 6d6d 656e  sty empty commen
00000220: 7420 7769 7468 206e 6f20 6e65 776c 696e  t with no newlin
00000230: 652c 206a 7573 7420 454f 463a 0a2f 2f20  e, just EOF:.// 
00000240: 6120 636f 6d6d 656e 7420 6174 2074 6865  a comment at the
00000250: 2065 6e64 206f 6620 7468 6520 6669 6c65   end of the file

@lengocthuong15
Copy link

Thank @AaronDMarasco

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants