summaryrefslogtreecommitdiff
path: root/support/regression/tests/bug-2833.c
blob: 41baaedec13b53a5c53c2861102e2c506aaca792 (plain)
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
/* bug-2833.c
   A problem resulting in compile-time error on some casts from bool to float.
 */

#include <testfwk.h>

#ifndef __SDCC_pdk14 // Lack of memory
float cast1 (float a)
{
  return !(int)a;
}

float cast2 (_Bool b)
{
  return b;
}

const float b0 = 0.0f;
const float b1 = 1.0f;
#endif

void testBug(void)
{
#ifndef __SDCC_pdk14 // Lack of memory
#if !(defined (__SDCC_pdk15) && defined(__SDCC_STACK_AUTO)) // Lack of code memory
  ASSERT (cast1 (1.0f) == b0);
  ASSERT (cast1 (0.0f) == b1);

  ASSERT (cast2 (0.0f) == b0);
  ASSERT (cast2 (1.0f) == b1);
#endif
#endif
}