This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/57853] pointer arithmetic on arrays


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57853

--- Comment #10 from Howard Brodale <brodhow at all2easy dot net> ---
Should we expect to see "as" in the for loop's printf, for arr[0][0]?  YES!
And, we do when the pointer arithmetic is NOT being done, above.

But, something changed arr[0] to "s" only!  What did that?

Did I change arr[0] like where I specified arr[0] = "s";?  NO! But, something
did!

Should the C code set arr[0] = "s"? NO! But, it did set a[0] to "s", only!

Thats whats happening, erroneously! For when we output array arr again or later
or after the pointer arithmetic operation is shown THEN, only "s" appears where
"as" used to be! And, also for every where else a[0] is being printed! After
the pointer arithmetic operation.

 This "s" problemm is being shown in the for loop's printf and every where else
a[0] is being outputed, AFTER the "++" operation. Where another "++" is not!
But, "a" is still not showing up, AFTER the initial "++" operation.

 Look at all the subsequent printfs, AFTER the "++" operation.  Where "as" used
to be now only "s" is being outputed.

 Do you see where the issue is first appearing? Then, by what C code statement
the issue is being done by?  Though "*++arr[0][0]" does output 's' (correctly);
something else is being done that should not be done! Setting *arr[0] EQUAL TO
"s"! Which is wrong!


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]