olli
if it is within the local scope it is fine
Scope has nothing to do with it
Anonymous
It violates strict aliasing rules?
in this case just have a case
Anonymous
cast
Anonymous
but this is not made for C++
Anonymous
it is made for C
Anonymous
Which cast?
reinterpret cast into a uint32_t* then dereference this
olli
Remember alias rules exist for casts as well
Anonymous
put this value inside the result.u32
Anonymous
UB
it is not
olli
Which of the rules applies?
olli
To make it valid
Anonymous
Anonymous
adhering to the C++ standard still nothing
olli
Do you think g++ is 100% ISO conform?
Anonymous
both pointed at types of uint32_t and uint8_t are similar
Anonymous
and you can send it in as a uint8_t* which he did
olli
and you can send it in as a uint8_t* which he did
Show me the code please. Cast from uint8 to uint32 is UB
Anonymous
so if you are super anal about it you can go: result.u32 = *((uint32_t*) data);
BinaryByter
ub doesnt mean that it HAS to break
Anonymous
Anonymous
there is NO warning
Anonymous
still in C++
Anonymous
same file i sent here
Dima
ub doesnt mean that it HAS to break
that’s the point, you never know
BinaryByter
ub doesnt have to be warned for
Anonymous
ub doesnt have to be warned for
pedantic will make it
olli
pedantic will make it
Therefore your compiler had to be 100% correct
Anonymous
Anonymous
see i even added -fsanitize
Anonymous
then find me a compiler which says it is undefined
Anonymous
it is easy for people who never wrote the C++ compiler to claim it is undefined but until you can physically prove it with ANY compiler
Anonymous
we have to say it is defined as the only compilations shown say it is defined
BinaryByter
in that case, the compiler either didn't catch it or isn't standard compliant
Anonymous
G++ is standard compilant
BinaryByter
no compiler is
BinaryByter
no C++ compiler is*
olli
G++ is standard compilant
G++ has several bugs
Anonymous
G++ has several bugs
ok so how about clang?
BinaryByter
clang might actually catch that UB
BinaryByter
but its still not compliant
Anonymous
Anonymous
what is that?
Anonymous
IT IS DEFINED
Anonymous
it is all local scoped
Anonymous
there is no strict aliasing as he uses array accesses
Anonymous
and copies those over
BinaryByter
IT IS DEFINED
not in the standard
olli
what is that?
Please show me the section in the standard that makes it well defined
Anonymous
this is under local scope
BinaryByter
it is
Show me please
Anonymous
https://isocpp.org/files/papers/n4296.pdf section 3.3.7
Anonymous
3.3.3 Block scope [basic.scope.block] 1 A name declared in a block (6.3) is local to that block; it has block scope . Its potential scope begins at its point of declaration (3.3.2) and ends at the end of its block. A variable declared at block scope is a local variable . 2 The potential scope of a function parameter name (including one appearing in a lambda-declarator ) or of a function-local predefined variable in a function definition (8.4) begins at its point of declaration. If the function has a function-try-block the potential scope of a parameter or of a function-local predefined variable ends at the end of the last associated handler, otherwise it ends at the end of the outermost block of the function definition. A parameter name shall not be redeclared in the outermost block of the function definition nor in the outermost block of any handler associated with a function-try-block . 3 The name declared in an exception-declaration is local to the handler and shall not be redeclared in the outermost block of the handler . 4 Names declared in the for-init-statement , the for-range-declaration , and in the condition of if , while , for , and switch statements are local to the if , while , for , or switch statement (including the controlled statement), and shall not be redeclared in a subsequent condition of that statement nor in the outermost block (or, for the if statement, any of the outermost blocks) of the controlled statement; see 6.4. my bad 3.3.3
Anonymous
Anonymous
for future reference cppreference is actually not affliated with the C++ standards
BinaryByter
this is not about "names"
Anonymous
I don't. How?
you using idf?
olli
https://isocpp.org/files/papers/n4296.pdf section 3.3.7
The problem (regarding unions) is about 12.3.1 in n4659
Anonymous
Anonymous
The problem (regarding unions) is about 12.3.1 in n4659
https://isocpp.org/files/papers/n4659.pdf
Anonymous
not found
Anonymous
that one is still being drafted
Anonymous
it is not valid until it is finished the review stage
@oleg
you using idf?
I use arduino ide)
Anonymous
I use arduino ide)
using the expressif toolset?
olli
that one is still being drafted
N4660 should be c++17, so n4659 is as close as you can get to the latest ISO standard for free
Anonymous
https://github.com/cplusplus/draft/blob/master/papers/n4659.pdf just read the first page
Anonymous
Anonymous
everyone can
olli
Where?
olli
Your link also provides only a working draft