[llvm-bugs] [Bug 24690] New: Suspicious function-try-block warning

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Sep 3 05:35:42 PDT 2015


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

            Bug ID: 24690
           Summary: Suspicious function-try-block warning
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: kaballo86 at hotmail.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
    Classification: Unclassified

The following snippet generates a warning for what I think is well-defined
behavior:

    #include <iostream>

    struct foo {
      int x;

      foo() try : x(42) { throw 1; } catch (...) { std::cout << x; }
    };

    int main() {}

The warning says "cannot refer to a non-static member from the handler of a
constructor function try block", but I cannot find any references to such
restriction in the standard.

I suspect this is derived from 15.2 [except.ctor]/3

> [...] The subobjects are destroyed in the reverse order of the completion of
> their construction. Such destruction is sequenced before entering a handler 
> of the function-try-block of the constructor or destructor, if any.

The lifetime of an object with a trivial-destructor does not end when the
destructor call starts, but rather when the storage which the object occupies
is released.

-- 
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/20150903/74c2aeaf/attachment.html>


More information about the llvm-bugs mailing list