Skip to content
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

test/21_char_array fails on host=ppc #40

Closed
GoogleCodeExporter opened this issue Mar 12, 2015 · 15 comments
Closed

test/21_char_array fails on host=ppc #40

GoogleCodeExporter opened this issue Mar 12, 2015 · 15 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?

test/21_char_array.c

What is the expected output? What do you see instead?

___test________________________
hello
h: 104
e: 101
l: 108
l: 108
o: 111
copied string is 
___expected____________________
hello
h: 104
e: 101
l: 108
l: 108
o: 111
copied string is hello
___diff________________________
7c7
< copied string is 

---
> copied string is hello

What version of the product are you using? On what operating system?
gcc version 4.1.2/linux/ppc/bigendian


Original issue reported on code.google.com by flameman...@gmail.com on 11 Sep 2009 at 9:38

@GoogleCodeExporter
Copy link
Author

it seems there is something wrong with pointers
i mean "*dest++ = *src++;" is not working as espected !


-------------------------------------------------------

test/21_char_array.c

int x = 'a';
char y = x;
char destarray[32];
char *a = "hello";

printf("%s\n", a);

int c;
int i;
c = *a;

char *b;
for (b = a; *b != 0; b++)
    printf("%c: %d\n", *b, *b);

char *dest = &destarray[0];
char *src = a;

i=0;
while (*src != 0)
      {
      *dest++ = *src++;
      }
*dest = 0;

printf("copied string is %s\n", destarray);

Original comment by flameman...@gmail.com on 11 Sep 2009 at 9:41

@GoogleCodeExporter
Copy link
Author

[deleted comment]

1 similar comment
@GoogleCodeExporter
Copy link
Author

[deleted comment]

@GoogleCodeExporter
Copy link
Author

the following is NOT working if i declare "array[17]" as char, while it is 
working if
i declare as int


int array[17];
char *src = "0123456789abcdef";

int i;

printf("msg=%s\n", src);


array[0]='c';
array[1]='i';
array[2]='a';
array[3]='o';
array[4]=0;


i=0;
while (*src != 0)
      {
      printf("step %d:   ", i);
      printf("%c ", *src);
      array[i] = *src;
      printf("[%c] ", array[i]);
      src++;
      i++;
      printf("\n");
      }
array[i]=0;

printf("phase2\n");

i=0;
while (array[i])
      {
      printf("step %d:   ", i);
      printf("[%c] ", array[i]);
      i++;
      printf("\n");




if i declare as char i get the following output

msg=0123456789abcdef
step 0:   0 [] 
step 1:   1 [] 
step 2:   2 [] 
step 3:   3 [] 
step 4:   4 [] 
step 5:   5 [] 
step 6:   6       printf("[%c] ", array[i]);
                             ^
array2.c:22: this  is not an array

Original comment by flameman...@gmail.com on 12 Sep 2009 at 12:41

@GoogleCodeExporter
Copy link
Author

i tested picoC on x86 (little endian): test_21 has success !

we have the confirm: there is an endianless issue in the code !!!

Original comment by flameman...@gmail.com on 12 Sep 2009 at 10:36

@GoogleCodeExporter
Copy link
Author

Hi flamemanii, I believe I've fixed this problem. Can you please test the most 
recent
version and see if it's ok now?

Original comment by zik.sale...@gmail.com on 30 Oct 2009 at 7:43

  • Changed state: Started

@GoogleCodeExporter
Copy link
Author

Calling this one closed unless I hear otherwise

Original comment by zik.sale...@gmail.com on 1 Nov 2009 at 4:53

  • Changed state: Fixed

@GoogleCodeExporter
Copy link
Author

it is not fixed!!!! i can't see any progress: show me the code in where there 
is no
that issue!!!

Original comment by flameman...@gmail.com on 1 Nov 2009 at 6:14

@GoogleCodeExporter
Copy link
Author

Reopened this issue at flamemanii's request.

Hi flamemaniii, thanks for checking this for me.

What exact platform did you try this on? Which picoc version did you test?

Original comment by zik.sale...@gmail.com on 1 Nov 2009 at 7:56

  • Changed state: Accepted

@GoogleCodeExporter
Copy link
Author

machine: ppc-g4,g3,450 also mips-be, hppa-be: all bigendian machines fails !

tested:
* picoc-0.92.tar.bz2
* svn checkout http://picoc.googlecode.com/svn/trunk/ picoc-read-only, Checked 
out
revision 359

is there an other version/branch?

make
cd test
tests # make
Test: 00_assignment...
Test: 01_comment...
Test: 02_printf...
Test: 03_struct...
Test: 04_for...
Test: 05_array...
Test: 06_case...
Test: 07_function...
Test: 08_while...
Test: 09_do_while...
Test: 10_pointer...
Test: 11_precedence...
Test: 12_hashdefine...
Test: 13_integer_literals...
Test: 14_if...
Test: 15_recursion...
Test: 16_nesting...
Test: 17_enum...
Test: 18_include...
Test: 19_pointer_arithmetic...
Test: 20_pointer_comparison...
Test: 21_char_array...
error in test 21_char_array
--- 21_char_array.expect        2009-10-30 22:57:15.000000000 +0100
+++ 21_char_array.output        2009-10-30 22:58:17.000000000 +0100
@@ -4,4 +4,4 @@
 l: 108
 l: 108
 o: 111
-copied string is hello
+copied string is
make: *** [21_char_array.test] Error 1


Original comment by flameman...@gmail.com on 1 Nov 2009 at 10:52

@GoogleCodeExporter
Copy link
Author

Thanks. I don't have access to a big endian machine at the moment but I'll see 
what I
can do to find the problem.

Original comment by zik.sale...@gmail.com on 2 Nov 2009 at 7:53

@GoogleCodeExporter
Copy link
Author

I finally got access to a G4 to look into this bug.

Fixed in revision #371

flamemaniii, please let me know if you still have any problems.

Original comment by zik.sale...@gmail.com on 3 Nov 2009 at 8:45

  • Changed state: Fixed

@GoogleCodeExporter
Copy link
Author

i manually grabbed your #371 diff and manually patched expression.c of the last
public release picoc-0.93

well, on my ppc7410 the "Test: 21_char_array" has now success, but it seams 
there is
an issue with fixed point math


make
Test: 00_assignment...
Test: 01_comment...
Test: 02_printf...
Test: 03_struct...
Test: 04_for...
Test: 05_array...
Test: 06_case...
Test: 07_function...
Test: 08_while...
Test: 09_do_while...
Test: 10_pointer...
Test: 11_precedence...
Test: 12_hashdefine...
Test: 13_integer_literals...
Test: 14_if...
Test: 15_recursion...
Test: 16_nesting...
Test: 17_enum...
Test: 18_include...
Test: 19_pointer_arithmetic...
Test: 20_pointer_comparison...
Test: 21_char_array...
Test: 22_floating_point...
Test: 23_type_coercion...
Test: 24_math_library...
error in test 24_math_library
--- 24_math_library.expect      2009-10-30 22:57:15.000000000 +0100
+++ 24_math_library.output      2009-11-04 14:39:23.000000000 +0100
@@ -1,18 +1,18 @@
-0.119712
-0.992808
-0.120579
-0.120289
-1.450506
-0.119428
-0.120288
-1.007208
-0.119427
+-1.0
+0.715645
+-1.397340
+-2147483648.0
+-2147483648.0
+-1.570796
+2147483647.//////e-126
+2147483647.//////e-2147483648
+-1.0
 1.127496
-0.12
--2.120263
--0.920818
-0.775357
-0.346410
-12.0
-13.0
-12.0
+-0.119999
+-2147483648.0
+-2147483648.0
+0.0
+-2147483648.0
+12.84
+12.34
+12.34
make: *** [24_math_library.test] Error 1

Original comment by flameman...@gmail.com on 4 Nov 2009 at 11:43

@GoogleCodeExporter
Copy link
Author

on HPPA1 (PA risc machine, PA7100LC, cpu family PA-RISC 1.1d)

tests # make
Test: 00_assignment...
Test: 01_comment...
Test: 02_printf...
Test: 03_struct...
Test: 04_for...
Test: 05_array...
Test: 06_case...
Test: 07_function...
Test: 08_while...
Test: 09_do_while...
Test: 10_pointer...
Test: 11_precedence...
Test: 12_hashdefine...
Test: 13_integer_literals...
Test: 14_if...
Test: 15_recursion...
Test: 16_nesting...
Test: 17_enum...
Test: 18_include...
Test: 19_pointer_arithmetic...
Test: 20_pointer_comparison...
Test: 21_char_array...
Test: 22_floating_point...
/bin/sh: line 1:  2912 Segmentation fault      ../picoc 22_floating_point.c 
2>&1 >
22_floating_point.output
make: [22_floating_point.test] Error 139 (ignored)
error in test 22_floating_point
--- 22_floating_point.expect    2009-11-04 13:02:07.000000000 +0100
+++ 22_floating_point.output    2009-11-04 13:06:24.000000000 +0100
@@ -1,16 +0,0 @@
-69.12
-69.12
--44.44
-700.6652
-0.217330
-1 1 0 0 0 1
-0 1 1 1 0 0
-0 0 0 1 1 1
-69.12
--44.44
-700.6652
-0.217330
-12.34
--12.34
-2.0
-0.909297
make: *** [22_floating_point.test] Error 1

Original comment by flameman...@gmail.com on 4 Nov 2009 at 12:08

@GoogleCodeExporter
Copy link
Author

Moving this new bug to issue #64.

Original comment by zik.sale...@gmail.com on 4 Nov 2009 at 6:45

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant