<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Bad code gen => uninitialized value"
href="https://bugs.llvm.org/show_bug.cgi?id=36344">36344</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Bad code gen => uninitialized value
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>5.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>-New Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>tydeman@tybor.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>/*
* Invalid runtime error: MemorySanitizer: use-of-uninitialized-value
* Due to bad code generation ????
* Using clang 5.0.1-1 on 64-bit Fedora Linux 27 on Intel core i5
# flags common to both compiler and linker
export CLFLAGS="-fsanitize=memory -fsanitize=undefined
-fno-sanitize=float-cast-overflow -fno-sanitize=float-divide-by-zero"
# flags for compiler
export CFLAGS="-std=c1x -m64 -mfpmath=sse -msse2 -O0 -fno-fast-math -pedantic
-fmath-errno"
*/
static void test_4(void){
si = func_si( 30*4+14, ((struct bit2){1u,1,1,BOOL_CAST(1)}.pibf), ((struct
bit2){1u,1,1,BOOL_CAST(1)}.pibf), ((struct bit2){1u,1,1,BOOL_CAST(1)}.pibf) );
ck(si);
si = func_si( 30*4+14, bits.pibf, bits.pibf, bits.pibf );
ck(si);
si = func_si( 30*4+15, ((struct bit2){1u,1,1,BOOL_CAST(1)}.bobf), ((struct
bit2){1u,1,1,BOOL_CAST(1)}.bobf), ((struct bit2){1u,1,1,BOOL_CAST(1)}.bobf) );
ck(si);
si = func_si( 30*4+15, bits.bobf, bits.bobf, bits.bobf );
ck(si);
}
#include <stdio.h>
#include <stdarg.h>
#include <stdbool.h>
#define BOOL_CAST(x) ((bool)(x))
#define ck(a) \
if(a){ \
NumPass++;\
ckFailed = 0;\
}else{\
NumFail++;\
ckFailed = 1;\
Line = __LINE__;\
(void)printf("\nError in line %d in %s\n", Line, __FILE__ );\
(void)puts( #a );\
}
static unsigned long int NumFail = 0uL;
static unsigned long int NumPass = 0uL;
static int ckFailed = 0;
static int Line = 0;
#define LDBL long double
static LDBL ld;
static signed int si;
struct bit2 {
unsigned int uibf : 7;
signed int sibf : 7;
/*plain*/ int pibf : 7;
bool bobf : 1;
unsigned char after[16];
} bits
= {1u,1,1,BOOL_CAST(1),{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}} ;
static signed int func_si( const int i, ... ){
va_list ap;
signed int x1, x2, x3;
va_start(ap,i);
x1 = ( signed int)va_arg(ap, signed int );
x2 = ( signed int)va_arg(ap, signed int );
x3 = ( signed int)va_arg(ap, signed int );
ck( x1 == x2 );
ck( x2 == x3 );
va_end(ap);
return x3;
}
static LDBL func_ld( const int i, ... ){
va_list ap;
LDBL x1, x2, x3;
va_start(ap,i);
x1 = (LDBL)va_arg(ap, LDBL );
x2 = (LDBL)va_arg(ap, LDBL );
x3 = (LDBL)va_arg(ap, LDBL );
#if 0 /* change to #if 1 showw that vars have values */
(void)printf(" i=%i\n", i);
(void)printf("x1=%Lg\n", x1);
(void)printf("x2=%Lg\n", x2);
(void)printf("x3=%Lg\n", x3);
exit(0);
#endif
ck( x1 == x2 ); /* invalid error happens here */
ck( x2 == x3 );
va_end(ap);
return x3;
}
static void test_4(void){
#if 1
si = func_si( 30*4+14, ((struct bit2){1u,1,1,BOOL_CAST(1)}.pibf), ((struct
bit2){1u,1,1,BOOL_CAST(1)}.pibf), ((struct bit2){1u,1,1,BOOL_CAST(1)}.pibf) );
ck(si);
si = func_si( 30*4+14, bits.pibf, bits.pibf, bits.pibf );
ck(si);
#endif
#if 1
si = func_si( 30*4+15, ((struct bit2){1u,1,1,BOOL_CAST(1)}.bobf), ((struct
bit2){1u,1,1,BOOL_CAST(1)}.bobf), ((struct bit2){1u,1,1,BOOL_CAST(1)}.bobf) );
ck(si);
si = func_si( 30*4+15, bits.bobf, bits.bobf, bits.bobf );
ck(si);
#endif
}
static void test_20(void){
ld = func_ld( 30*20+20, 1.5L, 1.5L, 1.5L );
ck(ld);
ld = func_ld( 30*20+20, ld, ld, ld );
ck(ld);
}
int main(void){
#if 1 /* change to #if 0 to make "error" go away */
test_4();
#endif
test_20();
(void)printf("No error happened.\n");
return 0;
}</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>