473,387 Members | 1,502 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Definition of 'evaluate'

Does the standard define the meaning of 'evaluate' ? Someone
in another newsgroup said they thought evaluating a pointer
meant dereferencing it, and I couldn't find any text to contradict
this.

Jul 24 '07 #1
2 1308
"Old Wolf" <ol*****@inspire.net.nzwrote in message
news:11**********************@d30g2000prg.googlegr oups.com...
Does the standard define the meaning of 'evaluate' ? Someone
in another newsgroup said they thought evaluating a pointer
meant dereferencing it, and I couldn't find any text to contradict
this.
If evaluating a pointer meant dereferencing it, the following code fragment
would have undefined behavior:

int* p = 0;
int* q = p;

because (a) initializing q requires evaluating p and (b) dereferencing a
zero pointer evokes undefined behavior.
Jul 25 '07 #2
Andrew Koenig a écrit :
"Old Wolf" <ol*****@inspire.net.nzwrote in message
news:11**********************@d30g2000prg.googlegr oups.com...
>Does the standard define the meaning of 'evaluate' ? Someone
in another newsgroup said they thought evaluating a pointer
meant dereferencing it, and I couldn't find any text to contradict
this.

If evaluating a pointer meant dereferencing it, the following code fragment
would have undefined behavior:

int* p = 0;
int* q = p;

because (a) initializing q requires evaluating p and (b) dereferencing a
zero pointer evokes undefined behavior.
That was a question I had (I didn't remember it):
3.5.4.2 note 4
The effect of using an invalid pointer value (including passing it to
adeallocation function) is undefined.

Is returning a pointer value actually 'using it' ?

The relevant example was:
int* f()
{
return reinterpret_cast<int*>(0x42424242);

}
Is calling f() UB because it returns an invalid pointer or is it just
using/deferencing the returned value that is UB ?

Michael
Jul 25 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: John Spiegel | last post by:
Hi all, Is it possible to have an uncompiled C# expression evaluated at runtime? I'd like to store an expression within an XML file then evaluate it when the time comes, something like: ...
5
by: Csaba Gabor | last post by:
In Firefox 1.5 (this question is Mozilla specific as I am using greasemonkey) I would like to be able to use document.evaluate to return the first TD entry that shows ^\s*MySearchText\s*$. As I...
9
by: joshc | last post by:
Hi, I have an array defined in one file with an intializer as follows: int arr = {0, 1, 2, 3}; I have a declaration of the array in another file as follows: extern int arr;
2
by: Björn Langhof | last post by:
Hello. I want to evaluate a XPath-Expression only on a subtree of the whole xml-document. 1. I select a node of the XML-document 2. Then a want to select specific nodes below the node chosen...
1
by: shellon | last post by:
Hi all: when I use XPather(a firefox extension) to evaluate the expression: "/html/body/table/tbody/tr/td/table/tbody/tr/td/div/ul/li" it tells me there are 7 matching Nodes. but when I use...
15
by: Phlip | last post by:
Javascripters: I have an outer page and an inner iframe. The outer page calculates some javascript, and wants the inner frame to run it. The inner frame should hit a page on the same (private)...
8
by: optimistx | last post by:
In excellent YAHOO user interface programs I see often extra parenthesis like this (foo=function(){ alert('I am foo'); })(); instead of bar=function(){
6
by: vasudevram | last post by:
Hi group, Question: Do eval() and exec not accept a function definition? (like 'def foo: pass) ? I wrote a function to generate other functions using something like eval("def foo: ....") but...
275
by: Astley Le Jasper | last post by:
Sorry for the numpty question ... How do you find the reference name of an object? So if i have this bob = modulename.objectname() how do i find that the name is 'bob'
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.