News for hackers. Stuff that matters.
Re:*(char*)0 = 0; - What Does the C++ Programmer Intend with... by gpderetta on Tuesday October 17, 2023 @03:37PM (#37920466)
> sizeof(char) (== 1 almost everywhere)

sizeof char is 1 by definition everywhere.

/pedantic

Re:*(char*)0 = 0; - What Does the C++ Programmer Intend with... by shric on Tuesday October 17, 2023 @08:36PM (#37923475)
> sizeof char is 1 by definition everywhere.

Parentheses are required around char because it's a type.

/pedantic

Re:*(char*)0 = 0; - What Does the C++ Programmer Intend with... by cjensen on Tuesday October 17, 2023 @09:54PM (#37924004)
That is incorrect :-).

sizeof is an operator in C, and does not need parenthesis any more than pointer operator *. It is true that programmers frequently think of it as a function and use parenthesis.

Re:*(char*)0 = 0; - What Does the C++ Programmer Intend with... by teo_zero on Wednesday October 18, 2023 @01:21AM (#37925076)
It's not that simple!

To begin with, sizeof has two syntaxes: the first, which is the one you seem to refer to, is simply

  sizeof expression
where expression involves variables and constants, not types. The second is

  sizeof (type)
where the parentheses are mandatory.

Then, even in the first syntax, even if sizeof is listed among the operators, even if it doesn't look any different from "pointer operator ", nonetheless it has strange priority rules. For example

  sizeof (T) *x
If it was a regular prefix operator obeying priority and right-to-left evaluation, this would mean: dereference x, cast it to T, and return its size. Instead the C standard forces the compiler to interpret it as: take the size of type T and multiply it by x.
Re:*(char*)0 = 0; - What Does the C++ Programmer Intend with... by shric on Wednesday October 18, 2023 @02:26AM (#37925415)
Hilariously I've been down voted, even though you absolutely need sizeof (char) because it's a type. Given char x; sizeof x is fine. I know sizeof is an operator. I've been using C for 40 years.
Re:*(char*)0 = 0; - What Does the C++ Programmer Intend with... by diath on Wednesday October 18, 2023 @03:27AM (#37925789)
That's incorrect, from GCC: error: expected parentheses around type name in sizeof expression.
Re:*(char*)0 = 0; - What Does the C++ Programmer Intend with... by lmm on Tuesday October 17, 2023 @10:49PM (#37924353)
In the mathematical sense of almost, a property that holds everywhere does qualify as holding almost everywhere.
Re:*(char*)0 = 0; - What Does the C++ Programmer Intend with... by sargstuff on Wednesday October 18, 2023 @10:21PM (#37937499)
unless initial property is start of dynamic operation, in which case, holding almost anywhere begins at the first operation after the start of the dynamic operation. process / lambda / epsilon calculi is just symbolic math. address 0 static, everything else dynamic.

per math, dimension N is static, to be able to "change things up" in dimension N, need to to be almost everywhere higher than dimension n. Edge cases are weird in any dimension. Guess why logicians just do the equivalent of C's !0

(cast classic logic) A=1 (cast boolean logic) B=0

C statement !(!B == A) hold everywhere and almost everywhere depends on how read C spec to interpret A & B.