Skip to content

[clang][clang-cl][x86] <unknown>:0: error: value evaluated as 264 is out of range. #62081

@romanholidaypancakes

Description

@romanholidaypancakes
  • test.cpp
#include "stdio.h"
#include <windows.h>

int main() { return 0; }
  • Generate assembly and edit the assembly file to add the following content
	call my_fun
	call my_fun
	call my_fun	
	call my_fun
	call my_fun
	call my_fun	
	call my_fun
	call my_fun
	call my_fun	
	call my_fun
	call my_fun
	call my_fun	
	call my_fun
	call my_fun
	call my_fun	
	call my_fun
	call my_fun
	call my_fun	
	call my_fun
	call my_fun
	call my_fun	
	call my_fun
	call my_fun
	call my_fun	
	call my_fun
	call my_fun
	call my_fun	
	call my_fun
	call my_fun
	call my_fun	
	call my_fun
	call my_fun
	call my_fun	
	call my_fun
	call my_fun
	call my_fun	
	call my_fun
	call my_fun
	call my_fun	
	call my_fun
	call my_fun
	call my_fun	
	call my_fun
	call my_fun
	call my_fun	
	call my_fun
	call my_fun
	call my_fun	
	call my_fun
	call my_fun
	call my_fun	
	call my_fun
	call my_fun
	call my_fun	
	my_fun:

clang

  • generate the program
	.text
	.def	@feat.00;
	.scl	3;
	.type	0;
	.endef
	.globl	@feat.00
.set @feat.00, 0
	.intel_syntax noprefix
	.file	"test.cpp"
	.def	main;
	.scl	2;
	.type	32;
	.endef
	.globl	main                            # -- Begin function main
	.p2align	4, 0x90
main:                                   # @main
.seh_proc main
# %bb.0:
	call my_fun
	call my_fun
	call my_fun	
	call my_fun
	call my_fun
	call my_fun	
	call my_fun
	call my_fun
	call my_fun	
	call my_fun
	call my_fun
	call my_fun	
	call my_fun
	call my_fun
	call my_fun	
	call my_fun
	call my_fun
	call my_fun	
	call my_fun
	call my_fun
	call my_fun	
	call my_fun
	call my_fun
	call my_fun	
	call my_fun
	call my_fun
	call my_fun	
	call my_fun
	call my_fun
	call my_fun	
	call my_fun
	call my_fun
	call my_fun	
	call my_fun
	call my_fun
	call my_fun	
	call my_fun
	call my_fun
	call my_fun	
	call my_fun
	call my_fun
	call my_fun	
	call my_fun
	call my_fun
	call my_fun	
	call my_fun
	call my_fun
	call my_fun	
	call my_fun
	call my_fun
	call my_fun	
	call my_fun
	call my_fun
	call my_fun	
	my_fun:
	push	rax
	.seh_stackalloc 8
	.seh_endprologue
	mov	dword ptr [rsp + 4], 0
	xor	eax, eax
	pop	rcx
	ret
	.seh_endproc
                                        # -- End function
	.section	.drectve,"yni"
	.ascii	" /DEFAULTLIB:libcmt.lib"
	.ascii	" /DEFAULTLIB:oldnames.lib"
	.ascii	" /FAILIFMISMATCH:\"_CRT_STDIO_ISO_WIDE_SPECIFIERS=0\""
	.ascii	" /DEFAULTLIB:uuid.lib"
	.ascii	" /DEFAULTLIB:uuid.lib"
	.addrsig
  • code compilation failed. It seems that if you call call my_fun greater than 50, you will get an error message, which should not be, as long as the instruction is valid, it should compile successfully
clang-cl test.asm
<unknown>:0: error: value evaluated as 271 is out of range.
<unknown>:0: error: value evaluated as 271 is out of range.

gcc

  • generate the program
	.file	"test.cpp"
	.intel_syntax noprefix
	.text
	.def	___main;	.scl	2;	.type	32;	.endef
	.section .rdata,"dr"
LC0:
	.ascii "hello world\0"
	.align 2
LC1:
	.ascii "h\0e\0l\0l\0o\0 \0w\0o\0r\0l\0d\0\0\0"
	.align 2
LC2:
	.ascii "`O}Y\26NLu\0\0"
	.text
	.globl	_main
	.def	_main;	.scl	2;	.type	32;	.endef
_main:
LFB516:
	call my_fun
	call my_fun
	call my_fun	
	call my_fun
	call my_fun
	call my_fun	
	call my_fun
	call my_fun
	call my_fun	
	call my_fun
	call my_fun
	call my_fun	
	call my_fun
	call my_fun
	call my_fun	
	call my_fun
	call my_fun
	call my_fun	
	call my_fun
	call my_fun
	call my_fun	
	call my_fun
	call my_fun
	call my_fun	
	call my_fun
	call my_fun
	call my_fun	
	call my_fun
	call my_fun
	call my_fun	
	call my_fun
	call my_fun
	call my_fun	
	call my_fun
	call my_fun
	call my_fun	
	call my_fun
	call my_fun
	call my_fun	
	call my_fun
	call my_fun
	call my_fun	
	call my_fun
	call my_fun
	call my_fun	
	call my_fun
	call my_fun
	call my_fun	
	call my_fun
	call my_fun
	call my_fun	
	call my_fun
	call my_fun
	call my_fun	
	my_fun:
	.cfi_startproc
	lea	ecx, [esp+4]
	.cfi_def_cfa 1, 0
	and	esp, -16
	push	DWORD PTR [ecx-4]
	push	ebp
	.cfi_escape 0x10,0x5,0x2,0x75,0
	mov	ebp, esp
	push	ecx
	.cfi_escape 0xf,0x3,0x75,0x7c,0x6
	sub	esp, 20
	call	___main
	mov	DWORD PTR [esp], OFFSET FLAT:LC0
	call	_printf
	mov	DWORD PTR [esp+12], 0
	mov	DWORD PTR [esp+8], OFFSET FLAT:LC1
	mov	DWORD PTR [esp+4], OFFSET FLAT:LC2
	mov	DWORD PTR [esp], 0
	mov	eax, DWORD PTR __imp__MessageBoxW@16
	call	eax
	sub	esp, 16
	mov	eax, 0
	mov	ecx, DWORD PTR [ebp-4]
	.cfi_def_cfa 1, 0
	leave
	.cfi_restore 5
	lea	esp, [ecx-4]
	.cfi_def_cfa 4, 4
	ret
	.cfi_endproc
LFE516:
	.ident	"GCC: (i686-win32-dwarf-rev0, Built by MinGW-W64 project) 8.1.0"
	.def	_printf;	.scl	2;	.type	32;	.endef
  • code compiled successfully
gcc.exe test.s

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions