Skip to content

Overflow exceptions missing when compiling with /ovf+ #1808

@cpyrgas

Description

@cpyrgas

There are no overflow exceptions thrown at runtime when numbers overflow by arithmetic operations, even if /ovf is enabled.

NOTE: Fixing this might cause problems in the X# runtime or user code that accidentally depends on this behavior. So we need to be very careful about fixing this and test a lot. Just logging it so it is not forgotten, but something to be looked at in the future, not now!!!

#pragma options (ovf,on)
#pragma options (fovf,on)
FUNCTION Start() AS VOID
	LOCAL dw AS DWORD
	LOCAL n AS INT

	dw := 1
	dw -= 2 // no exception
	? dw:ToString()
	n := Int32.MaxValue
	n ++  // no exception
	? n:ToString()
	
	// this one does thrown an overflow exception
//	n := -1
//	dw := (DWORD) n
	
	BEGIN CHECKED
		dw := 1
//		dw -= 2 // withing a CHECKED section, overflow exception does get thrown
	END CHECKED

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions