Page 1 of 1

Build error using thread statistics

Posted: Sun Aug 08, 2021 8:34 pm
by andypiper
Seeing this in the newest ChibiOS release:

../../modules/ChibiOS/os/rt/include/chschd.h: In function 'void ch_sch_prio_insert(ch_queue_t*, ch_queue_t*)':
../../modules/ChibiOS/os/rt/include/chschd.h:509:26: error: cast from 'ch_queue_t* {aka ch_queue*}' to 'thread_t* {aka ch_thread*}' increases required alignment of target type [-Werror=cast-align]
(((thread_t *)cp)->hdr.pqueue.prio >= ((thread_t *)tp)->hdr.pqueue.prio));

Re: Build error using thread statistics

Posted: Mon Aug 09, 2021 7:46 am
by Giovanni
Hi,

Moving in bug reports.

Giovanni

Re: Build error using thread statistics

Posted: Fri Aug 13, 2021 5:24 pm
by andypiper
Giovanni wrote:Hi,

Moving in bug reports.

Giovanni


Any idea how to fix? I can just turn off the warning but don't know if that is safe or not.

Andy

Re: Build error using thread statistics

Posted: Fri Aug 13, 2021 6:18 pm
by Giovanni
I haven't looked into it yet. Try to put an intermediate cast to void* in there.

Giovanni

Re: Build error using thread statistics

Posted: Sun Aug 15, 2021 8:41 am
by Giovanni
Hi,

I examined several occurrences of this error, there are several of those, but the code is safe as is.

-Werror=cast-align is not a default option, why are you using it? are you using some peculiar setup?

Note that none of the tested compilers complains about it: GCC, LLVM, Keil, IAR.

Giovanni

Re: Build error using thread statistics

Posted: Sun Aug 15, 2021 11:54 am
by Giovanni
Hi,

Update, I modified things to be compatible with "-Wcast-align=strict". I think you are compiling the code using the C++ compiler (correct?), this is why you are seeing the warnings.

I fixed all casts to (thread_t *), post here if you find more instances of the problem. Cleaning things up is always a good thing.

Giovanni

Re: Build error using thread statistics

Posted: Mon Aug 16, 2021 1:50 pm
by andypiper
Giovanni wrote:Hi,

Update, I modified things to be compatible with "-Wcast-align=strict". I think you are compiling the code using the C++ compiler (correct?), this is why you are seeing the warnings.

I fixed all casts to (thread_t *), post here if you find more instances of the problem. Cleaning things up is always a good thing.

Giovanni


Yes, C++ compiler - great thanks!