Re: Lets put it another way
On May 25, 2:59 am, "Paul" <pchris...@yahoo.co.uk> wrote:
"Joshua Maurice" <joshuamaur...@gmail.com> wrote in message
--Take the following program:
-- #include <stdlib.h>
-- #include <stdio.h>
-- int main()
-- { char* a = (char*)malloc(1);
-- char* b = a;
-- free(a);
-- printf("%p\n", b);
-- }
--This program has UB in C, and as I said will likely have UB in C++, or
--it already is UB in C++. See the defect report for more details:
--http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_260.htm
This is not the same as what I did.
Yes it is.
--And I still don't know what you mean by array type object vs array
--object. Until you explain that technical distinction to me, you're
--literally just spouting effective nonsense, as you just invented thos=
e
--terms and no one else knows what you're saying.
Well consider the following:
int arr[3]={0};
std::cout<< arr;
The above does not output an array object, it outputs a memory address.
To output the array object you need to loop and dereference:
for (int i=0; i<3; ++i){
std::cout<< arr[i] << std::endl;
}
The array type object is a region of memory that contains a value that =
is
some memory address.
The array object is a region of memory than contains three integer
objects,
each with the value 0.
--I suggest you take a course in compilers, or read a book, like one of
--the Dragon Books, Red or Green. You have gross misunderstandings of
--both the C++ object model, and how compilers actually generate code.
--There is no such thing as an "array-type object", as you've defined
--it. In these examples, there are only array objects and pointer
--objects - including pointers to arrays and pointers to individual
--elements, not "array-type objects".
If there is no such thing as an array type object then what is the object
that is implicitly converted to a pointer, and stores a memory address?
--Consider:
-- void foo()
-- { int x[3];
-- int* y = x;
-- cout << y;
-- }
--"x" is a piece of text. It is a preprocessor token. It is an
--identifier for an auto (stack) variable. It names an object. It names
--an (array) object of type "int [3]". That array object has three sub-
--objects of type "int".
std::cout<< x;
//outputs a memory address.
std::cout<< typeid(x).name();
//outputs that x is an array type object.
"x" is an object that stores a memory address.
"x" is an array type object.
When the array to pointer conversion takes place what is converted to a
pointer?
It is not one of the three integer objects that is converted to a pointer=
,
it is the array type object.
--"y" is a piece of text. It is a preprocessor token. It is an
--identifier for an auto (stack) variable. It names an object. It names
--a (pointer) object of type "int*". It holds the address of the first
--element of the auto (stack) array x.
y is a pointer.
This function "uses" the following objects:
- the array object x, and its 3 unnamed int sub-objects,
- the pointer object y,
- the object cout.
-There is no "array-type object".
Thats your opinion but you do not acknoweldge the object that stores the
address of the array, the object that is converted to a pointer on assign=
emt
to y.
<snip>
That's nice. You're welcome to join the adult discussion when you
decide to adopt the community's terms instead of inventing your own.
Good day troll or obstinate person.