[llvm-bugs] [Bug 46342] New: std::variant compiles with exception handling

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jun 16 01:46:16 PDT 2020


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

            Bug ID: 46342
           Summary: std::variant compiles with exception handling
           Product: libc++
           Version: 10.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Standards Issues
          Assignee: unassignedclangbugs at nondot.org
          Reporter: nmmm at e-nick.org
                CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com

This code includes exception handling. It must not include it, since both int
and double are exception safe types:

#include <variant>

int main(){
    using V = std::variant<int, double>;
    V a = 5;
    V b = 5.6;

    a.swap(b);
}

Problem might be in standard library, since this does not emit exception handle
code:

#include <variant>

template<class T>
void sw(T &a, T &b){
    auto c = a;
    a = b;
    b = c;
}

int main(){
    using V = std::variant<int, double>;

    V a = 5;
    V b = 5.6;

    sw(a, b);
}

https://stackoverflow.com/questions/62404209/why-this-stdvariant-code-includes-exception-handling

-- 
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/20200616/d14fc89a/attachment.html>


More information about the llvm-bugs mailing list