Retro C++ quiz #58

Given the following in C++:

int main() {
int arr[10][20]{};

auto x = arr[1,2] ;
}

Without checking the type of x is:

A. int
B. int*
C. Depends on standard version
D. The initialization is Ill-formed

#Cplusplus
#Cpppolls

A
3.4%
B
27.6%
C
55.2%
D
13.8%
Poll ended at .

Retro C++ quiz #57

Given the following in C++:

#include <cstdint>
#include <limits>

int main() {
int64_t s=32;
int64_t x=std::numeric_limits<int32_t>::max();

1 << s; // A
1 + x; // B
}

Without checking, assuming LP64, which invokes undefined behavior:

A. Both
B. None
C. A
D. B

#Cplusplus
#Cpppolls

A
36.4%
B
27.3%
C
31.8%
D
4.5%
Poll ended at .

Retro C++ quiz #56

Given the following in C and C++ (assume correct header is included):

int main(void) {
int n = sizeof(0)["abcdefghij"];
printf("%d\n",n);
}

Without checking, assuming LP64, what’s the result:

C | C++
=========
A. 1 | 1
B. 101 | 101
C. 1 | 101
D. 101 | 1

#Cplusplus
#Cpppolls
#Programming

A
20%
B
46.7%
C
26.7%
D
6.7%
Poll ended at .

Retro C++ quiz #55

Given the following in C++:

void f(int);
void f(short);
void f(long);

And the call to f() below:

void g(){
f(0u);
}

Assuming LP64, which f() is chosen:

A. f(int)
B. f(short)
C. f(long)
D. ambiguous can’t choose

#Cplusplus
#Cpppolls

A
56.3%
B
0%
C
31.3%
D
12.5%
Poll ended at .

#311 Given the following in C++

#include <iostream>

int f(int x) {
std::cout << x;
return x;
}

int main() {
[a=f(0),b=f(1)](){}();
}

Without checking, what is outputted?

A. 01
B. 10
C. Could be A or B

#Cplusplus
#Cpppolls

A
50%
B
3.8%
C
46.2%
Poll ended at .

Retro C++ quiz #54

Given the following in C and C++:

void f(void);

void f() {
const const int x=1;
}

This is, without checking:

A. Valid C99 and C++
B. Valid C99
C. Valid C++
D. Neither Valid C99 or C++

#Cplusplus
#CppPolls
#Programming

A
23.1%
B
30.8%
C
19.2%
D
26.9%
Poll ended at .

#310 Given the following in C++

struct A {
const int :1; // Well-formed?
};

Without checking:

A. Yes
B. No

#Cplusplus
#Cpppolls

A
56.5%
B
43.5%
Poll ended at .

Retro C++ quiz #53

Given the following in C++:

#include <iostream>

struct A {
operator int() {return 1;}
};
bool operator==(A, int){return 0;}

What is the result of:

int main() {
std::cout <<(1 == A{})<<"\n";
}

A. 1
B. 0
C. Ill-formed
D. Depends on standard version

#Cplusplus
#Cpppolls

A
37.1%
B
8.6%
C
11.4%
D
42.9%
Poll ended at .

Retro C++ quiz #52

Given the following C code

#include <stdio.h>

int main(void) {
for (size_t i=0;i<6;++i) {
typedef int VLA[i++];
printf("%zu",i);
}
}

W/o checking what is the output?

A. 012345
B. 135
C. ¯\_(ツ)_/¯ undefined behavior
D. Varies on standard version

#CPolls
#cpppolls
#Programming

A
14.8%
B
33.3%
C
33.3%
D
18.5%
Poll ended at .

Retro C++ quiz #51

Given the following in C++:

struct A {
virtual void f() = +0;
};

Without checking, is this:

A. Well-formed
B. Ill-formed (requires a diagnostic)
C. Depends on the standard version

#Cplusplus
#Cpppolls

A
27.6%
B
55.2%
C
17.2%
Poll ended at .