[llvm-bugs] [Bug 27378] New: [seh] Returnig non-const value from __finally causes verifier error

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Apr 15 12:33:49 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=27378

            Bug ID: 27378
           Summary: [seh] Returnig non-const value from __finally causes
                    verifier error
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: d.zobnin.bugzilla at gmail.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

$ clang -v

clang version 3.9.0 (cfe/trunk 266451)
Target: x86_64-pc-windows-msvc
Thread model: posix
-----------------------------------------------


Consider the following code:

---------------------1.cpp---------------------
int f() {
  int x;
  __try {
  }
  __finally {
    return x;
  }
}
-----------------------------------------------
$ clang -c 1.cpp
-------------------Output----------------------

1.cpp:6:5: warning: jump out of __finally block has undefined behavior
      [-Wjump-seh-finally]
    return x;
    ^
Instruction referencing instruction not embedded in a basic block!
  %x = bitcast i8* %0 to i32*
  <badref> = load i32, i32* %x, align 4
fatal error: error in backend: Broken function found, compilation aborted!



When a function call is used in return, the error message is different:

---------------------1.cpp---------------------
int g() { return 5; }


int f() {
  int x;
  __try {
  }
  __finally {
    return g();
  }
}
-----------------------------------------------
$ clang -c 1.cpp
-------------------Output----------------------
1.cpp:9:5: warning: jump out of __finally block has undefined behavior
      [-Wjump-seh-finally]
    return g();
    ^
Global is referenced by parentless instruction!
i32 ()* @"\01?g@@YAHXZ"
; ModuleID = '1.cpp'
  %call = call i32 @"\01?g@@YAHXZ"()
fatal error: error in backend: Broken module found, compilation aborted!



If constant value is returned, Clang doesn't emit errors:

---------------------1.cpp---------------------
int f() {
  const int x = 0;
  __try {
  }
  __finally {
    return x + 10;
  }
}
-----------------------------------------------
$ clang -c 1.cpp

Emits only warning.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160415/16cfe475/attachment.html>


More information about the llvm-bugs mailing list