With two calls to memset() in the same function using constant expressions one of them will get the incorrect address. In fact, it appears to re-use the address of the first call.
I don't think this is related to #3564104; the problem here occured when adding to a pointer literal the result of the addition was given the type of the pointer, including its original literal value. In bug #3564104, the base pointer is a variable, so there is no literal value to inadvertently copy with the type.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
View and moderate all "bugs Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Bugs"
View and moderate all "bugs Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Bugs"
membug.c contains build instructions, compiler version and more specifics of the problem which I'd meant to put in the description.
This excerpt from membug.asm shows HL loaded with 0x8000 in both instances rather than 0x9000 in second as it should.
;membug.c:9: memset((char *)0x8000, 1, 0x1000);
ld hl,#0x8000 ; Correct
ld (hl), #0x01
ld e, l
ld d, h
inc de
ld bc, #0x0FFF
ldir
;membug.c:10: memset((char *)0x8000 + 0x1000, 2, 0x1000);
ld hl,#0x8000 ; WRONG
ld (hl), #0x02
ld e, l
ld d, h
inc de
ld bc, #0x0FFF
ldir
ret
_main_end::
This happens for all ports, and even for a trivial example:
void g(void *);
void f(void)
{
g((char *)0);
g((char *)0 + 1);
}
will pass 0 to both calls. This issue might be related to #3564104.
Increasing priority to 7, since bad code is generated silently.
Philipp
Fixed in revision #8096.
I don't think this is related to #3564104; the problem here occured when adding to a pointer literal the result of the addition was given the type of the pointer, including its original literal value. In bug #3564104, the base pointer is a variable, so there is no literal value to inadvertently copy with the type.