[llvm-bugs] [Bug 26216] New: compiling w -fno-exceptions generates errors on "throw" in templates that are never instantiated

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jan 19 19:08:37 PST 2016


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

            Bug ID: 26216
           Summary: compiling w -fno-exceptions generates errors on
                    "throw" in templates that are never instantiated
           Product: clang
           Version: trunk
          Hardware: Macintosh
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: mclow.lists at gmail.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
    Classification: Unclassified

I ran into this in the libc++ test suite.

If -fno-exceptions is defined, the following code compiles w/o error using GCC,
but gets an error with clang.

My expectation matches gcc's behavior; no error should be generated
unless/until the template is instantiated.

Reproducer:

#include <iostream>
#include <stdexcept>

template <typename T>
struct wrap {
    wrap() : t_() {}
    wrap(const T& t) : t_(t) {}

    T & get() { return t_; }
    void toss () { throw std::runtime_error("Toss"); }
    T t_;
};

int main() {
    std::cout << "Hello World" << std::endl;
    }

-- 
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/20160120/734e8dc1/attachment-0001.html>


More information about the llvm-bugs mailing list