Hi there!
'-pedantic-errors' flag begin enabled makes only difference to CLANG
(x86-64 clang (trunk)) compilation result.
All the compilations were done by means of godbolt.org, C compilers.
As somebody proposed, we can do a small trick by means of using "void*"
conversion and it works fine:
"void subfunc(struct zzz const * const * const arg) {
if (arg != NULL) {
printf("%s", "Done!");
}
}
void subfunc2(void * arg) {
subfunc(arg);
}
void func(struct zzz ** arr_of_ptr, unsigned count) {
subfunc2(arr_of_ptr); // ОК!
}".
But I don't like the idea of converting "Foo**" -> "void*" -> "const Foo*
const * const".
As it was previously discussed some conversions might be unsafe and they
are usually accompanied by a compiler warning (some of them are described
in C FAQ, see the e-mail thread).
But in our case, we are just using a conversion to "all-const-pointer" and,
the rationale behind is providing a stable INVARIANT while designing C code.
As for now, nobody has pointed out the place where C standard explicitly
prohibits such kind of conversion. OR, just a place (inside C standard or C
FAQ) where such kind of conversion is described and
explained to be unsafe.
So, per my understanding it is a little bit early to talk about ways of
showing diagnosize messages.
Respectfully,
Aleksandr G Povaliev.
пт, 28 нояб. 2025 г. в 05:58, Andrey Tarasevich <[email protected]>:
> No, no, no...
>
> What you have in your code is a _hard_ _solid_ _error_ in C language. More
> pedantically, it is a _constraint_ _violation_ - a specific kind of
> problem,
> which makes your code flat out invalid and requires a diagnostic message
> from your compiler.
>
> Remember, that we do not have concepts of "warnings" or "errors" in C
> language. We only have a concept of "diagnostic message". When a C
> compiler
> encounters a constraint violation it is required to issue a diagnostic
> message. _Any_ diagnostic message. What the message actually says does not
> matter ("warning" or "error" - does not matter). Whether the compilation
> is aborted after that message does not matter either. However, once such
> message is issued, your code no longer qualifies as a valid C program.
>
> So, if your compiler decided to issue a "warning" for this code, it is
> just
> a quirk of your compiler or a quirk of your specific compiler setup. Your
> compiler just happens to be set up to report [some] hard errors as mere
> "warnings" (and to continue translation of the code). Formally, the
> compiler is not is the wrong here, since issuing _any_ diagnostic
> message is sufficient to meet the standard requirements.
>
> However, under such compiler setup it becomes your responsibility
> to catch such "warnings" and realize that they are not mere "warnings" (as
> you seem to incorrectly believe), but rather hard errors.
>
> Alternatively, if you want the compiler to help you with this and report
> hard errors as "errors", you might try supplying '-pedantic-errors' flag
> as part of its configuration (at least in case of GCC or Clang). The
> very purpose of this flag is to force the compiler to report language
> errors
> as "error" messages (and abort compilation). It is not always perfect, but
> it might be of use if you care to write your code in pedantically
> correct standard C language.
>
> Now, if (as you claim) Intel C compiler compiles this code completely
> silently, it would indicate either that Intel compiler is broken or
> that someone forcefully configured it into some awfully non-compliant
> mode. Either way, a compiler that issues no diagnostic message for a
> constraint violation is not a compliant C compiler. (BTW, are you sure you
> are compiling the code as C and not as C++?)
>
> ––
> Best regards,
> Andrey
>