[Bug c/57853] pointer arithmetic on arrays

2016-06-03 Thread brodhow at sbcglobal dot net
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57853

Howard Brodale  changed:

   What|Removed |Added

 CC||brodhow at sbcglobal dot net

--- Comment #13 from Howard Brodale  ---
I want to delete this bug now but, I don't have the same email address now that
I used to create my first account here with.

[Bug c/57853] pointer arithmetic on arrays

2016-06-03 Thread brodhow at sbcglobal dot net
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57853

--- Comment #14 from Howard Brodale  ---
My email address now is brod...@sbcglobal.net

[Bug c/57853] pointer arithmetic on arrays

2016-06-03 Thread brodhow at sbcglobal dot net
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57853

--- Comment #15 from Howard Brodale  ---
The arr pointer is being set to the incremented value which is the 2nd element
in the array to start from as the arr[0] value, then.

[Bug c/57853] pointer arithmetic on arrays

2016-07-12 Thread brodhow at sbcglobal dot net
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57853

--- Comment #16 from this is me  ---
Andrew Pinski:

  Will you delete this Bug 57853 web page for me? 
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57853

  I can't hired!

Howard
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57853
>
> Andrew Pinski  changed:
>
> What|Removed |Added
> 
>   Status|UNCONFIRMED |RESOLVED
>   Resolution|--- |INVALID
>
> --- Comment #8 from Andrew Pinski  ---
>> "*++arr[0][0]" is not supposed to change the array arr!
> At this point I am going to say you don't know C and should ask on a C mailing
> list learning C.
>
> *++arr[0][0] does the following:
> ++arr[0][0]
> And then deferences that value (which turns into 's').
>
>
> If you only want (arr[0][0])[1] then use that or *(arr[0][0]+1) rather than 
> ++.
>

[Bug c/57853] pointer arithmetic on arrays

2016-07-15 Thread brodhow at sbcglobal dot net
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57853

--- Comment #17 from this is me  ---
Its simpler than what Andrew was describing! It is simply incrementing by 1
character datatype width to the next character with "++".

[Bug c/57853] pointer arithmetic on arrays

2016-07-16 Thread brodhow at sbcglobal dot net
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57853

--- Comment #18 from this is me  ---
This is why C arrays are not pointers. It was possible to easily misconstrue
datatypes like especially with imported variables. Defined as a short integer
in one file but, is being used as a character in another file. Here, the 1
datatype width (in "++") here can be narrower with a short integer so when the
cpu tries access a wider character's datatype width then, thats where
segmentation faults or bus errors come from! 

 Seg faults can still happen even now with the extreme datatype checking
between calling arguments and received parameters! How? Like when defining a
structure then using it! Before allocating any memory for it, still!  Some
things never change.

 So, a pointer can point to anything but, they're not all of the same datatype
width nature! This is what C arrays are not pointers! C arrays can hold any
type of data too! Where the indexing uses different number values as to which
datatype it is. See "Expert C Programming" by Peter Van Der Linden. Where he
says that it is shocking! C arrays are not pointers!

He also says that the C array indexing is based on a commutative math formula
where a + b = c and b + a = c! Or, here absolute address + datatypewidth offset
= relative address or datatypewidth offset + absolute address = relative
address! As in:

#include 

void main(){

  char cat[4] = {'C', 'A', 'T' };
  int i = 0;

  printf("the char is %c\n", cat[0]);
  printf("the char is %c\n", cat[1]);
  printf("the char is %c\n", 2[cat]); // what does this print?

}

/Programming/C$ gcc Mario.c -o mari
/Programming/C$ ./mari
the char is C
the char is A
the char is T

 Theres no array named '2'! Theres no index variable called "cat"! So! Whats
going on? a + b = c and b + a = c! Or, here absolute address + datatypewidth
offset = relative address or datatypewidth offset + absolute address = relative
address! 

 Its still true today! Even with today's C compilers! 2[cat] still prints 'T'!