[go: up one dir, main page]

File: s-return.c

package info (click to toggle)
uftrace 0.13-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 5,212 kB
  • sloc: ansic: 53,313; python: 9,846; makefile: 838; asm: 703; cpp: 602; sh: 560; javascript: 191
file content (61 lines) | stat: -rw-r--r-- 752 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <float.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>

struct large {
	char buf[4096];
};

struct small {
	unsigned char bit : 1;
};

struct large return_large(char patt)
{
	struct large l;

	memset(l.buf, patt, sizeof(l.buf));

	return l;
}

#if __clang__
__attribute__((optnone))
#endif
struct small
return_small(void)
{
	struct small s = { .bit = 1 };
	return s;
}

#if __clang__
__attribute__((optnone))
#endif
long double
return_long_double(void)
{
	return LDBL_MAX;
}

int main(void)
{
	struct large l;
	struct small s;
	long double ld;

	l = return_large(1);
	if (l.buf[10] != 1)
		return 1;

	s = return_small();
	if (s.bit != 1)
		return 1;

	ld = return_long_double();
	if (ld != LDBL_MAX)
		return 1;

	return 0;
}