Skip to content

[Bug]: USR call is removed by optimizer #1027

@oskostenko

Description

@oskostenko

Contact Details

No response

Compiler version

v1.18.4

What happened?

sub DoSomething
    print "YES"
end sub

a = usr(@DoSomething)

When compiled with the default optimization level, this program prints nothing, while it is expected to print YES.

The compiler's optimizer detects the value assigned to the variable a is unused and removes the whole instruction, including the usr call. However, usr is not a pure function so it must not be removed by optimizer.

Workaround: instead of usr write your own sub like this:

sub fastcall Call(address as uinteger)
    asm
        jp (hl)
    end asm
end sub

Call @DoSomething

Error and Warning messages

warning: [W150] Variable 'a' is never used

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions