Author Topic: BUG: Killer comment!  (Read 13174 times)

Offline gammac

  • Jr. Member
  • *
  • Posts: 71
  • Country: 00
BUG: Killer comment!
« on: June 27, 2014, 04:49:19 PM »
Win32 version of NASM
NASM version 2.11.05 compiled on May 21 2014

Code: [Select]

; I'm a comment and I'm a killer bug \
label  nop
         nop
         jz label


Code: [Select]
error: symbol `label' undefined
A comment it's a comment it's a comment!!!


EDIT: I'ts allready known: http://bugzilla.nasm.us/show_bug.cgi?id=3392256
« Last Edit: June 27, 2014, 05:42:38 PM by gammac »
Please comment your code! It helps to help you.

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: BUG: Killer comment!
« Reply #1 on: June 27, 2014, 06:13:45 PM »
Sorry the line-continuation character doesn't work the way you (and Linuxero) think it should. It does what it does.

Now, %comment and %endcomment not working as documented - that's a bug. (maybe)

Best,
Frank


Offline gammac

  • Jr. Member
  • *
  • Posts: 71
  • Country: 00
Re: BUG: Killer comment!
« Reply #2 on: June 27, 2014, 07:02:20 PM »
Normaly a single-line comment starts at their starting-delimeter and ends at the next newline character. Everything between starting-delimeter and newline character should be treated as ordinary character. That is what I'm thinking.

Something like this should not leading into an error:

Code: [Select]

; \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \
; \ \
; \ \                            This it's my realy good new function. I'm so proud! ;)
; \ \
; \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \
my_func: push ebp
...

Please comment your code! It helps to help you.

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: BUG: Killer comment!
« Reply #3 on: June 27, 2014, 07:11:03 PM »
Hmmm... the line-continuation character is documented (section 3.1), but is not listed in the contents or index (or I'm going blind - also true). That could perhaps be improved.

The problem, you see, is that Nasm needs to "get" a line before it could possibly preprocess or parse a line. That's where the line continuation character does its work. So Nasm has no way to determine if it's a comment or not. It continues the line, period.

You're not the first one to be bitten by this. I can understand:
Code: [Select]
5Bh ; [
5Ch ; \
5Dh ; ] <- gone bye-bye

What made you end the line with a backslash if you didn't intend it to be continued?

Best,
Frank


Offline gammac

  • Jr. Member
  • *
  • Posts: 71
  • Country: 00
Re: BUG: Killer comment!
« Reply #4 on: June 27, 2014, 07:41:25 PM »
The problem, you see, is that Nasm needs to "get" a line before it could possibly preprocess or parse a line.

Yes, NASM simply should ignore everything after a ';' character and should start parsing again right behind the next newline character. Thats the normal behavior, I think only NASM looks what kind of character is the last character in an outcommented line.

Code: [Select]
5Bh ; [
5Ch ; \
5Dh ; ] <- gone bye-bye
What made you end the line with a backslash if you didn't intend it to be continued?

EDIT: Your code snippet is a good exsample to show that NASM's behaviour it's very closed to a bug.

EDIT: I think NASM it's a bit lazy, if it's first doing is concatenating all lines that ends with a '\' - character. Or you could say, it's prioraty it's to high.

« Last Edit: June 27, 2014, 08:32:42 PM by gammac »
Please comment your code! It helps to help you.