Bug 33775 - Memset
Summary: Memset
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: testsuite (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-10-15 05:44 UTC by swalliu
Modified: 2007-11-09 18:16 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description swalliu 2007-10-15 05:44:36 UTC
H:\DOWNLOAD\gcc-4.2.2\gcc-4.2.2\gcc\testsuite\gcc.c-torture\execute\builtins\lib

memset.c: line 15
   n[(char *) dst] = c;  => (char *) dst[n] = c;
Comment 1 Andrew Pinski 2007-10-15 11:14:26 UTC
This code written as a[(char*)b] is valid even C code, in C, d[e] is the same as *(d+e) so d[e] is the same as e[d].  So the code is valid and does the correct thing.  There is no bug here.  Unless you can explain exactly why you want the change, I am going to close this as invalid.
Comment 2 Johan Walles 2007-11-09 13:13:02 UTC
IMO the proposed change would make the code more readable.
Comment 3 Manuel López-Ibáñez 2007-11-09 18:16:56 UTC
(In reply to comment #2)
> IMO the proposed change would make the code more readable.

Johan, the code you quote is in a file from the testsuite. Such code is used to test for some correct behavior under various circumstances. Therefore, there is typically a very good reason for the code to be written like that. Moreover, in the testsuite you will find not only unreadable code but also code that is broken on purpose to test that the compiler can handle such code.