[LLVMbugs] [Bug 5206] New: logical operators should produce bool instead of int in C++
bugzilla-daemon at cs.uiuc.edu
bugzilla-daemon at cs.uiuc.edu
Thu Oct 15 16:46:07 PDT 2009
http://llvm.org/bugs/show_bug.cgi?id=5206
Summary: logical operators should produce bool instead of int in
C++
Product: clang
Version: trunk
Platform: All
OS/Version: All
Status: ASSIGNED
Severity: normal
Priority: P2
Component: Semantic Analyzer
AssignedTo: zhanyong.wan at gmail.com
ReportedBy: zhanyong.wan at gmail.com
CC: llvmbugs at cs.uiuc.edu, nlewycky at google.com
C++ 5.[14,15]: the && and || operators produce a bool.
C has no bool type and thus the rule is different there:
C99 6.5.[13,14]: the && and || operators produce an int.
Currently clang always thinks the result is an int (the C99 behavior). It
should consider the result type bool in C++ mode.
Proposed addition to test/SemaCXX/bool.cpp:
// static_assert_arg_is_bool(x) compiles only if x is a bool.
template <typename T>
void static_assert_arg_is_bool(T x) {
bool* p = &x;
}
void test2() {
int n = 2;
static_assert_arg_is_bool(n && 4);
static_assert_arg_is_bool(n || 5);
}
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list