Build error using thread statistics Topic is solved

Report here problems in any of ChibiOS components. This forum is NOT for support.
Post Reply
andypiper
Posts: 65
Joined: Sat Oct 24, 2020 5:21 pm
Has thanked: 5 times
Been thanked: 4 times

Build error using thread statistics

Post 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));
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Build error using thread statistics

Post by Giovanni »

Hi,

Moving in bug reports.

Giovanni
andypiper
Posts: 65
Joined: Sat Oct 24, 2020 5:21 pm
Has thanked: 5 times
Been thanked: 4 times

Re: Build error using thread statistics

Post 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
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Build error using thread statistics

Post by Giovanni »

I haven't looked into it yet. Try to put an intermediate cast to void* in there.

Giovanni
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Build error using thread statistics

Post 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
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Build error using thread statistics

Post 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
andypiper
Posts: 65
Joined: Sat Oct 24, 2020 5:21 pm
Has thanked: 5 times
Been thanked: 4 times

Re: Build error using thread statistics

Post 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!
Post Reply