English 中文(简体)
Is `*-p's actual legal (well formation) in C++03
原标题:Is `*--p` actually legal(well formed) in C++03

我很想知道这一法典样本:

int main()
{
   char *p ;
   char arr[100] = "Hello";
   if ((p=arr)[0] ==  H ) // do stuffs
}

这部法典在C++03中是否实际形成良好?

我的论点是,<代码>=的副作用只有在下一个序列点之后才能完成,因为我们正在取得<编码>p=arr的结果。 该代码可能尚未形成,在<代码>=和<代码>之间没有指令。

我是否正确?

行为在C和C++11中都有明确界定。 这部法律实际上源自MySQL。

最佳回答

当然,它非常明确。

当转让<代码>p=arr时,该编号为t事项。 发生。 页: 1 无论是否储存,其价值都不会改变,无论是否修改了<代码>p<>>/code>。

同样,在<代码>*-p中,没有明确的行为。 如果在顺序各点之间有两次接触同一变量,包括至少一次书写,则只有没有界定的行为。 但<代码>p作为<代码>-p的一部分仅存一次。 斜线再读(*p),倾斜的操作者适用于-p的成因,该数值是明确的点值。

如今,这并非明确的行为:

void* a;
void* p = &a;
reinterpret_cast<void**>(p = &p)[0] = 0;

——

int *pi = new int[5];
int i = **&++pi;

很显然,预先计算的结果并非与书面的顺序不符,因为有人声称存在一种种族,即:++p永远不能用作高价值,在这种情况下,它必须单独地在顺序各点之间,而后加固则可以加以利用。 无论是选入前还是选入后,都不会有任何好处。

问题回答

暂无回答




相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签