nbnet icon indicating copy to clipboard operation
nbnet copied to clipboard

Use of reserved identifier names invokes undefined behaviour

Open Phireh opened this issue 4 years ago • 0 comments

According to https://en.cppreference.com/w/c/language/identifier

The following identifiers are reserved and may not be declared in a program (doing so invokes undefined behavior): 
[...]
2. All external identifiers that begin with an underscore.
3. All identifiers that begin with an underscore followed by a capital letter or by another underscore (these reserved identifiers allow the library to use numerous behind-the-scenes non-external macros and functions).

Identifiers like those in extern NBN_MemoryManager __mem_manager (violates 2., 3.) or struct __NBN_Connection { ... }; (violates 3.) could cause the compiler to see adjacent code as UB and optimize it in a destructive way.

Phireh avatar Dec 30 '21 20:12 Phireh