[Bug 1069] New: /21_strings/char_traits/requirements/wchar_t/1.cc 1 FAIL

[email protected]
Newsgroups gmane.linux.lsb.test-suite
Message-ID <[email protected]>
Noticed that this bug is present on gcc-3_4-branch, gcc-4_0-branch as well as HEAD.

  // char* X::move(char* s, const char* p, size_t n)
  // for each i in [0,n) performs X::assign(s[i], p[i]). Copies
  // correctly even where p is in [s, s + n), and yields s.
  wchar_t array1[] = {L'z', L'u', L'm', L'a', L' ', L'b', L'e', L'a', L'c',
L'h',  0};
  const wchar_t str_lit1[] = L"montara and ocean beach";
  int len = sizeof(str_lit1) + sizeof(array1) - 1; // two terminating chars
  wchar_t array2[len];
  std::char_traits<wchar_t>::copy(array2, L"boracay, philippines", len);

Here, len is 24 * sizeof (wchar_t) + 11 * sizeof (wchar_t) - 1,
so on architectures we care about 139.

The std::char_traits<wchar_t>::copy(array2, L"boracay, philippines", len); call
is supposed to 139 times assign a wchar_t from the source array to destination
array, but wcslen(L"boracay, philippines")+1
(aka sizeof(L"boracay, philippines")/sizeof(wchar_t)) is just 21.
So the above call copies 118 wchar_t's beyond the end of the wide string
literal.  If we are lucky, it works and just copies random characters from
there. But in the _21_strings_char_traits_requirements_wchar_t_1.exe binary in
the LSB ppc32 testsuite we aren't that lucky:

 10000e28 00000062 0000006f 00000072 00000061  ...b...o...r...a
 10000e38 00000063 00000061 00000079 0000002c  ...c...a...y...,
 10000e48 00000020 00000070 00000068 00000069  ... ...p...h...i
 10000e58 0000006c 00000069 00000070 00000070  ...l...i...p...p
 10000e68 00000069 0000006e 00000065 00000073  ...i...n...e...s
 10000e78 00000000
  [13] .rodata           PROGBITS        10000d88 000d88 00014c 00   A  0   0  4
  [14] .sdata2           PROGBITS        10000ed4 000ed4 000000 00   A  0   0  4
  [15] .eh_frame_hdr     PROGBITS        10000ed4 000ed4 00001c 00   A  0   0  4
  [16] .eh_frame         PROGBITS        10000ef0 000ef0 00006c 00   A  0   0  4
  [17] .ctors            PROGBITS        10011000 001000 000008 00  WA  0   0  4

This means there are only 97 wchar_t's beyond end of the
L"boracay, philippines" character literal before we reach
end of page and a PROT_NONE mapping next to it.

The int len = sizeof(str_lit1) + sizeof(array1) - 1; // two terminating chars
should be int len = (sizeof(str_lit1) + sizeof(array1)) / sizeof(wchar_t) - 1;
// two terminating chars
and std::char_traits<wchar_t>::copy(array2, L"boracay, philippines", len);
shouldn't copy len bytes, but just sizeof (L"boracay, philippines") / sizeof
(wchar_t) at most.


===================
10|146 /21_strings/char_traits/requirements/wchar_t/1.cc 11:51:52|TC
Start
200|146 1 11:51:52|TP Start
520|146 1 0 1 1|DejaGNUTest.command_1:
520|146 1 0 1 2|
DejaGNUTest.command_1:
/opt/lsb/test/lib/qmtest_libstdcpp_3.4.3/_21_strings_char_traits_requirements_wchar_t_1.exe
520|146 1 0 1 3|DejaGNUTest.command_1:
520|146 1 0 1 4|DejaGNUTest.command_1:
520|146 1 0 1 5|DejaGNUTest.command_status_1: 11
520|146 1 0 1 6|DejaGNUTest.result_1: FAIL:
21_strings/char_traits/requirements/wchar_t/1.cc execution test
520|146 1 0 1 7|INFO: qmtest.cause:
21_strings/char_traits/requirements/wchar_t/1.cc execution test
520|146 1 0 1 8|INFO: qmtest.end_time: 2005-08-22T07:51:52Z
520|146 1 0 1 9|INFO: qmtest.start_time: 2005-08-22T07:51:52Z
520|146 1 0 1 10|INFO: qmtest.target: local
220|146 1 1 11:51:52|FAIL   
 
--    
Configure bugmail: http://bugs.linuxbase.org/userprefs.cgi?tab=email   
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.