-
-
Notifications
You must be signed in to change notification settings - Fork 264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Assigning enum to static array results in compiler crash (Win64) #2882
Comments
void foo() { char[64] buf1 = "\0"[0..0]; }I was wondering what that actually produces, and in fact, it's horrible: @.str = private unnamed_addr constant [1 x i8] zeroinitializer ; [#uses = 1]
...
define void @void onlineapp.foo()() #0 comdat {
%buf1 = alloca [64 x i8], align 1 ; [#uses = 2, size/byte = 64]
%1 = bitcast [64 x i8]* %buf1 to i8* ; [#uses = 1]
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %1, i8* align 1 getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i32 0, i32 0), i64 64, i1 false)
%2 = bitcast [64 x i8]* %buf1 to i8* ; [#uses = 1]
%3 = insertvalue { i64, i8* } { i64 64, i8* undef }, i8* %2, 1 ; [#uses = 0]
ret void
}What do you actually expect to happen? You're trying to initialize 64 bytes with a 0-length slice, whose underlying payload is a single 0-byte. Do you expect that 0-byte to be copied as first element and the remaining 63 bytes to be left uninitialized? [That'd be |
|
Yep, this seems like invalid code that should be a compiler error at first glance. |
|
I am totally fine with this being a compiler error. I was just porting code from c++ where |
|
Ah, okay. D actually initializes UTF8 chars with |
|
Filed upstream: https://issues.dlang.org/show_bug.cgi?id=19639 |
|
The segfault was fixed by dlang/dmd#9321. I filed another issue wrt. |
The following code crashes LDC:
Note that the following does not:
I use the enum in my code to ensure that empty, static strings are also zero terminated and are non-null. I just noticed this issue in LDC 1.8.0 when porting some c++ code and upgraded to 1.12.0 but the problem remained.
Using Windows 7 on x64, crashing with any configuration of options i tried.
Log:
Dmp file info:
The text was updated successfully, but these errors were encountered: