Skip to content

String merging broken on Windows

#9577 (closed) introduced string literal merging via the linker. Unfortunately I haven't been able to get this to function on Windows, resulting in testsuite failures of #9577 (closed).

Even gcc appears to do the wrong thing here,

$ cat hi.c
#include <stdio.h>
const char *hi = "hello world";
extern const char *hi2;
void main() { 
    printf("%p %p", hi, hi2);
}
$ cat hi2.c
const char *hi2 = "hello world";
$ gcc -c hi.c; gcc -c hi2.c; gcc -fmerge-all-constants hi2.o hi.o
$ ./a.exe 
0x100403040 0x100403030
$ gcc -s hi2.c
$ cat hi2.s
	.file	"hi2.c"
	.globl	hi
	.section .rdata,"dr"
.LC0:
	.ascii "hello world\0"
	.data
	.align 8
hi:
	.quad	.LC0
	.ident	"GCC: (GNU) 5.3.0"
Trac metadata
Trac field Value
Version 8.0.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC Phyx-
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information