[cfe-dev] Random small issues
Daniel Dunbar
daniel at zuster.org
Sat Oct 18 19:19:13 PDT 2008
Thanks for the reports Timo!
On Sat, Oct 18, 2008 at 1:05 PM, Timo Sirainen <tss at iki.fi> wrote:
> I tried compiling Dovecot using clang. The blocker problem was that
> va_arg() isn't implemented. Other than that there are a few other small
> issues:
va_arg of structures, I presume? va_arg should sort of work for other
things.
>
> 1. automake's dependency tracking doesn't work with ccc for some reason.
> It always recompiles everything. I didn't bother trying to figure out
> why.
I'm not sure what "automake's dependency tracking" translates to. clang/ccc
doesn't support -MM and friends yet, http://llvm.org/PR2618, which could
very well be the problem.
>
>
> 2. Some small differences with ccc/clang and gcc cause warnings and
> compiler errors:
>
> // gcc thinks these types are compatible, clang doesn't
> struct foo {
> int x;
> };
>
> int main(void) {
> const struct foo *src;
>
> if (!__builtin_types_compatible_p(struct foo, typeof(*src)))
> printf("error\n");
> return 0;
> }
Filed for discussion here: http://llvm.org/PR2919
>
> // noreturn attribute is useful also for function pointers, but
> // clang gives a warning
> static void (*fatal)(void) __attribute__((noreturn));
>
> static void __attribute__((noreturn))
> die(void)
> {
> fatal();
> }
>
> int main(void) {
> fatal();
> return 0;
> }
Fixed here: http://llvm.org/viewvc/llvm-project?view=rev&revision=57778,
confirmation appreciated.
>
> // clang gives a warning, gcc doesn't. I guess gcc figures out that
> // a format argument is going in so it should also be coming out.
> // That's how I also prefer it (unless there's another way to
> // prevent the warning?)
> static const char * __attribute__((format_arg(1)))
> printf_format_fix(const char *format)
> {
> // maybe modify format
> return format;
> }
>
> int main(void) {
> printf(printf_format_fix("%s"), "hello");
> return 0;
> }
Honestly I'm not sure what is going on here. Note that by default clang
applies more stringent default warnings than (my) gcc, however I do see gcc
as not warning on this code. Feel free to file a bug on this, but I'm not
really sure what the desired behavior is.
- Daniel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20081018/4dc40a21/attachment.html>
More information about the cfe-dev
mailing list