sequence-points Questions

1

Solved

As known, that standard C++11 guarantees that temporary object passed to a function will have been created before function call: Does standard C++11 guarantee that temporary object passed to a func...
Nil asked 15/8, 2016 at 11:34

2

Solved

Does standard C++11 guarantee that all 3 temporary objects have been created before the beginning performe the function? Even if temporary object passed as: object rvalue-reference passed only mem...
Symons asked 8/8, 2016 at 20:2

1

In this post, the OP contains code where there is a lot wrong with, but 1 line made me especially curios, since I wasn't able to look anything up, disallowing it. This is the specific line: int n ...
Shiekh asked 12/7, 2016 at 11:38

1

Solved

In the following code int main(){ int a=3; printf("%d %d %d",++a,a,a++); return 0; } As specified, From C99 appendix C:, The following are the sequence points described in 5.1.2.3: The...
Bulter asked 22/1, 2016 at 16:12

3

Solved

I read here that there is a sequence point: After the action associated with input/output conversion format specifier. For example, in the expression printf("foo %n %d", &a, 42), there is a ...
Brubeck asked 6/1, 2016 at 16:16

1

Solved

In C/C++, the second statement in int i = 0; int j = i++ + i++ + ++i; invokes both unspecified behavior, because the order of evaluation of operands is unspecified, and undefined behavior, bec...
Daffie asked 21/9, 2015 at 22:11

6

Solved

I've looked at a bunch of questions regarding sequence points, and haven't been able to figure out if the order of evaluation for x*f(x) is guaranteed if f modifies x, and is this different for f(x...
Glim asked 10/9, 2015 at 14:22

5

Solved

Why does (*p=*p) & (*q=*q); in C trigger undefined behavior if p and q are equal. int f2(int * p, int * q) { (*p=*p) & (*q=*q); *p = 1; *q = 2; return *p + *q; } Source (Nice article...
Anaphase asked 28/6, 2015 at 13:29

5

Solved

During my preparation to exam on ANSI C I have encountered the following question - Is following statement valid? If not, please make required changes to make it valid. The original stateme...
Alleyne asked 8/5, 2015 at 10:28

1

Solved

Let's just take for example the specific compound assignment operator ^=. This stackoverflow page says modification of the left operand may have not been done after the evaluation of ^=, and thus m...

2

In another answer it was stated that prior to C++11, where i is an int, then use of the expression: *&++i caused undefined behaviour. Is this true? On the other answer there was a little di...
Intervention asked 11/2, 2015 at 21:45

1

Solved

Assume one has a function with the following prototype template<typename T> std::unique_ptr<T> process_object(std::unique_ptr<T> ptr); The function may return (a moved version...
Alrich asked 23/1, 2015 at 14:18

3

Solved

I would like to do something like this #include <iostream> #include <memory> struct Foo {}; using FooPtr = std::unique_ptr<Foo>; FooPtr makeFoo() { return FooPtr(new Foo()); }...
Risner asked 17/12, 2014 at 17:35

1

Pre-C++11 we know that short-circuiting and evaluation order are required for operator && because of: 1.9.18 In the evaluation of the following expressions a && b a || b a ? ...
Tetrachord asked 15/11, 2014 at 5:42

2

Solved

I understand that C uses the notion of sequence points to identify ambiguous computations, and that = operator is not a sequence point. However, I am unable to see any ambiguity in executing ...

2

Solved

Suppose following piece of code: #include <iostream> using namespace std; char one() { cout << "one\n"; return '1'; } char two() { cout << "two\n"; return '2'; } int main(...
Markel asked 23/8, 2014 at 20:52

2

Solved

I understand that this is undefined behavior: int i = 0; int a[4]; a[i] = i++; //<--- UB here because the order of evaluation of i for the left hand side and the right hand side are undefined (...

5

Solved

I know that the following is undefined because I am trying to read and write the value of variable in the same expression, which is int a=5; a=a++; but if it is so then why the following code sn...
Z asked 24/3, 2014 at 7:53

4

Solved

The title is a bit vague as I don't really know how to define this question. It has to do with the following code: for (match = root, m_matchBase = match->requestedBase, m_matchLength = matc...
Convection asked 17/1, 2014 at 19:5

4

Solved

C99 §6.5 Expressions (1) An expression is a sequence of operators and operands that specifies computation of a value, or that designates an object or a function, or that generates side effects, ...
Dg asked 11/1, 2014 at 19:4

10

Solved

I stumbled into this code for swapping two integers without using a temporary variable or the use of bitwise operators. int main(){ int a=2,b=3; printf("a=%d,b=%d",a,b); a=(a+b)-(b=a); printf...
Whitecap asked 27/12, 2013 at 12:24

1

Solved

Is the comma (,) a sequence point in std::initializer_list? example: is this UB or not: #include <vector> int main() { auto nums = [] { static unsigned x = 2; return ( x++ % 2...
Ichthyolite asked 28/11, 2013 at 12:23

2

Solved

This is yet another sequence-point question, but a rather simple one: #include <stdio.h> void f(int p, int) { printf("p: %d\n", p); } int g(int* p) { *p = 42; return 0; } int main() { ...
Telegenic asked 29/8, 2013 at 16:38

3

Solved

In this C-FAQ it is give about sequence point; The Standard states that; Between the previous and next sequence point an object shall have its stored value modified at most once by the evaluat...
Hedrick asked 4/7, 2013 at 15:15

4

Solved

The allegedly "clever" (but actually inefficient) way of swapping two integer variables, instead of using temporary storage, often involves this line: int a = 10; int b = 42; a ^= b ^= a ^= b; /...

© 2022 - 2025 — McMap. All rights reserved.