File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -320,8 +320,13 @@ MathLib::bigint MathLib::characterLiteralToLongNumber(const std::string& str)
320320 return 0 ; // for unit-testing...
321321 if (str.size ()==1 )
322322 return str[0 ] & 0xff ;
323- if (str[0 ] != ' \\ ' )
324- throw InternalError (0 , " Internal Error. MathLib::toLongNumber: Unhandled char constant " + str);
323+ if (str[0 ] != ' \\ ' ) {
324+ // C99 6.4.4.4
325+ // The value of an integer character constant containing more than one character (e.g., 'ab'),
326+ // or containing a character or escape sequence that does not map to a single-byte execution character,
327+ // is implementation-defined.
328+ return str[0 ] & 0xff ;
329+ }
325330
326331 switch (str[1 ]) {
327332 case ' x' :
Original file line number Diff line number Diff line change @@ -271,6 +271,7 @@ class TestMathLib : public TestFixture {
271271
272272 // from char
273273 ASSERT_EQUALS ((int )(' A' ), MathLib::toLongNumber (" 'A'" ));
274+ ASSERT_EQUALS ((int )(' A' ), MathLib::toLongNumber (" 'ABC'" ));
274275 ASSERT_EQUALS ((int )(' \0 ' ), MathLib::toLongNumber (" '\\ 0'" ));
275276 ASSERT_EQUALS ((int )(' \r ' ), MathLib::toLongNumber (" '\\ r'" ));
276277 ASSERT_EQUALS ((int )(' \x12 ' ), MathLib::toLongNumber (" '\\ x12'" ));
You can’t perform that action at this time.
0 commit comments