5 ms·
This is not true. Undefined behaviour can mean that ``` bool b; if (b) printf("1 "); if (!b) printf("2 "); ``` might print `1 2 `.
by enedil 6y ago
This is not true. Undefined behaviour can mean that
```
bool b;
if (b) printf("1 ");
if (!b) printf("2 ");
```
might print `1 2 `.
- MaxBarraclough 6y agoRight on. Unless the compiler documentation promises a consistent handling of the various triggers of undefined behaviour, it is under no obligation to always generate code that handles UB consistently. To my knowledge there is no C compiler that promises to always handle all forms of UB consistently. The closest you could get would probably be something like Valgrind.
- pjmlp 6y agoAt least for this specific case Microsoft and Google are fixing it by always initializing the variables.
- greyhair 6y agoIt's not like that is hard to fix, and modern compilers will flag uninitialized variables. Use your brain and use your tools. C is not really that hard for a large number of problem sets.
- pjmlp 6y agoYet, CVE database is full of well known companies that apparently lack such developers. If their salaries cannot find them, where are they? Do we have a candidate to prove their secure reports as being wrong?
- MaxBarraclough 6y ago> It's not like that is hard to fix In an embedded context, such bugs may be extremely costly to fix, if it's even possible. > modern compilers will flag uninitialized variables Reading uninitialized variables is one of the more easily prevented forms of undefined behaviour. As pjmlp points out, undefined behaviour in C/C++ programs is one of the major sources of security vulnerabilities in today's software.