User account creation filtered due to spam.
gcc 4.7.0 20111029 (experimental) in C++0x mode rejects the following code:
typedef decltype(sizeof(0)) size_type;
constexpr size_type cstrlen_impl(const char* s, size_type i)
return s[i] ? cstrlen_impl(s, i + 1) : i;
constexpr size_type cstrlen(const char* s)
return s ? cstrlen_impl(s, 0) : throw 0;
constexpr size_type operator "" _lenraw(const char* digits)
static_assert(1_lenraw == 1, "Ouch"); // OK
static_assert(0_lenraw == 1, "Ouch"); // Error
The error I'm getting is:
main.cpp|19|error: non-constant condition for static assertion|
main.cpp|19| in constexpr expansion of 'operator"" _lenraw(0u)'|
main.cpp|15| in constexpr expansion of 'cstrlen(digits)'|
main.cpp|10|error: expression '<throw-expression>' is not a constant-expression|
This allows the conclusion, that the octal integer literal '0' is incorrectly handled, instead of the expected string length of 1 the raw literal operator gets a NULL string pointer. This seems to violate 2.14.8 p3 where 'n' would be equal to '0' which should lead to the effective string literal argument "0" in this case.
I have a patch to address a resolution issue.
For some reason, this bug doesn't show up in that version.
I'll try to understand this bug but ultimately (and soon) I'd like to put a version of that patch in and call it done.
(In reply to comment #1)
I have now tested gcc 4.7.0 20111105, but the problem still seems to exist. I can reproduce it on Windows XP 32 bit and Windows 7 64 bit.
Created attachment 25839 [details]
Patch to correctly resolve literal operators.
Literal operators were not properly resolved according to . This means that there could be mismatches between the literal and the literal operator that is used to resolve it.
This patch also fixes this bug.
Date: Mon Nov 21 19:27:30 2011
New Revision: 181595
* parser.c (lookup_literal_operator): New.
(cp_parser_userdef_char_literal): Use it.
(cp_parser_userdef_numeric_literal): Use it.
(cp_parser_userdef_string_literal): Use lookup_name.
* expr.c (cpp_userdef_char_remove_type): Fix typo.