here is the code:
DWORD SomeFunction(DW ORD Dw_0, DWORD Dw_1, DWORD Dw_2)
{
return Dw_0 + Dw_1 + Dw_2;
}
void main()
{
DWORD Dw = 0;
DWORD pDw[3] = {1,2,3};
DWORD Dw_Sum = SomeFunction(pD w[Dw++], pDw[Dw++], pDw[Dw++]);
}
I expected VC++ 2008 generate code as SomeFunction(3, 2,1) or
SomeFunction(1, 2,3), however, the real code is like
SomeFunction(1, 1,1)
I debug the and watch assembly code, find the code was generated with
push pDw[0] 3 times, then increase Dw by 3 times.
Can anyone tell me why? 2 1263 br*****@gmail.c om wrote:
here is the code:
DWORD SomeFunction(DW ORD Dw_0, DWORD Dw_1, DWORD Dw_2)
{
return Dw_0 + Dw_1 + Dw_2;
}
void main()
{
DWORD Dw = 0;
DWORD pDw[3] = {1,2,3};
DWORD Dw_Sum = SomeFunction(pD w[Dw++], pDw[Dw++], pDw[Dw++]);
}
I expected VC++ 2008 generate code as SomeFunction(3, 2,1) or
SomeFunction(1, 2,3), however, the real code is like
SomeFunction(1, 1,1)
I debug the and watch assembly code, find the code was generated with
push pDw[0] 3 times, then increase Dw by 3 times.
Can anyone tell me why?
This code has undefined behaviour, Dw++ is executed three times but it
is not defined when exactly that happens. This is quite classic example
like x = i++ + i++;
br
ismo br*****@gmail.c om wrote:
here is the code:
DWORD SomeFunction(DW ORD Dw_0, DWORD Dw_1, DWORD Dw_2)
{
return Dw_0 + Dw_1 + Dw_2;
}
void main()
{
DWORD Dw = 0;
DWORD pDw[3] = {1,2,3};
DWORD Dw_Sum = SomeFunction(pD w[Dw++], pDw[Dw++], pDw[Dw++]);
}
I expected VC++ 2008 generate code as SomeFunction(3, 2,1) or
SomeFunction(1, 2,3), however, the real code is like
SomeFunction(1, 1,1)
I debug the and watch assembly code, find the code was generated with
push pDw[0] 3 times, then increase Dw by 3 times.
Can anyone tell me why?
brof:
Please don't multi-post. This question has nothing to do with .NET, so it should
not be here anyway.
--
David Wilkinson
Visual C++ MVP This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: jr |
last post by:
Sorry for this very dumb question, but I've clearly got a long way to go!
Can someone please help me pass an array into a function. Here's a starting
point.
void TheMainFunc()
{
// Body of code...
TCHAR myArray;
DoStuff(myArray);
|
by: Tom Page |
last post by:
Hello all
I have a question that may or may not be simple - I need my three
dimensional array to be of the form:
array
where jj and kk range from 0 to some constant fixed at the very beginnning
of the program (currently 20) but goes from 0 to some boundary that
depends on calculations performed within the program. I know it is possible
|
by: VK |
last post by:
Whatever you wanted to know about it but always were affraid to ask.
<http://www.geocities.com/schools_ring/ArrayAndHash.html>
|
by: ulyses |
last post by:
I'm trying to put pointer to flexible array of structures in other
structure. I want to have pointer to array of pixels in screen
structure. Here is mine code, but I think it isn't quite all right:
struct pixel
{
int x;
int y;
int color;
};
|
by: Paul Morrison |
last post by:
Hi,
I am new to Javascript and am having a bit of difficulty. On my site, in
order for a member to unsubscribe from an article, they go to
the'Unsubscribe' page where they get a table of all of the articles that
they are subscribed to. There is a table with each article, and a checkbox
next to each article. For each checked checkbox it should send the value of
the checkbox to stop_subscription.php.
I have used the following...
| |
by: gcary |
last post by:
I am having trouble figuring out how to declare a pointer to an array
of structures and initializing the pointer with a value. I've looked
at older posts in this group, and tried a solution that looked
sensible, but it didn't work right. Here is a simple example of what
I'm trying to accomplish:
// I have a hardware peripheral that I'm trying to access
// that has two ports. Each port has 10 sequential
// registers. Create a...
|
by: Peter Olcott |
last post by:
http://groups.google.com/group/comp.lang.c++/msg/a9092f0f6c9bf13a
I think that the operator() member function does not work correctly, does
anyone else know how to make a template for making two dimensional arrays from
std::vectors ??? I want to use normal Array Syntax.
|
by: Ivan |
last post by:
Hi,
What is the best syntax to use a char to index into an array.
///////////////////////////////////
For example
int data;
data = 1;
|
by: Adam Chapman |
last post by:
Hi,
Im trying to migrate from programming in Matlab over to C. Im trying
to make a simple function to multiply one matrix by the other. I've
realised that C can't determine the size of a 2d array, so im
inputting the dimensions of those myself.
The problem is that the output array (C=A*B) has as many rows as A and
as many columns as B. I would think of initialising C with:
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |