[LLVMbugs] [Bug 22213] New: basic_regex::assign breaks *this if it throws regex_error
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Mon Jan 12 21:09:28 PST 2015
http://llvm.org/bugs/show_bug.cgi?id=22213
Bug ID: 22213
Summary: basic_regex::assign breaks *this if it throws
regex_error
Product: libc++
Version: unspecified
Hardware: All
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: All Bugs
Assignee: unassignedclangbugs at nondot.org
Reporter: kariya_mitsuru at hotmail.com
CC: llvmbugs at cs.uiuc.edu, mclow.lists at gmail.com
Classification: Unclassified
Created attachment 13681
--> http://llvm.org/bugs/attachment.cgi?id=13681&action=edit
clang++ -v
The sample code below should output "true\ntrue\n" but it outputs
"true\nfalse\n" if it is compiled by clang 3.6.0.
=============================== sample code ===============================
#include <iostream>
#include <string>
#include <regex>
int main()
{
static const char s[] = "abc";
std::regex re("abc");
try {
re.assign(std::string("(def"), std::regex_constants::ECMAScript);
} catch (const std::regex_error& e) {
std::cout << std::boolalpha <<
(e.code() == std::regex_constants::error_paren) << std::endl;
}
std::cout << std::boolalpha << std::regex_search(s, re) << std::endl;
}
===========================================================================
================================= output ==================================
true
false
===========================================================================
cf. http://melpon.org/wandbox/permlink/r2GhrrkaKfGZGnd8
The C++11 standard 28.8.3[re.regex.assign]/p.15 says, "If an exception is
thrown, *this is unchanged."
So I think that the output should be
================================= output ==================================
true
true
===========================================================================
--
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/20150113/6ca68e08/attachment.html>
More information about the llvm-bugs
mailing list