buglwIP - A Lightweight TCP/IP stack - Bugs: bug #33545, Then MEM_USE_POOLS defined...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #33545: Then MEM_USE_POOLS defined mem_malloc returns unaligned pointer.

Submitted by:  zg <zg0>
Submitted on:  Sun 12 Jun 2011 12:16:51 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: Crash ErrorStatus: Fixed
Privacy: PublicAssigned to: Simon Goldschmidt <goldsimon>
Open/Closed: ClosedPlanned Release: None
lwIP version: Other

(Jump to the original submission Jump to the original submission)

Sun 26 Jun 2011 05:33:35 PM UTC, comment #7:

Fixed, thanks for reporting.

Simon Goldschmidt <goldsimon>
Project AdministratorIn charge of this item.
Mon 13 Jun 2011 09:21:46 PM UTC, comment #6:

OK, I should have said "integral type" which I inferred because any size int is obviously (to me) any size of an integral type, as opposed to being a float. Thanks for looking it up, I should have but I know the standard better than most - the point was sizeof(enum) doesn't have to be sizeof(int) which both of us stated.

Bill Auerbach <billauerbach>
Mon 13 Jun 2011 08:46:16 PM UTC, comment #5:

sizeof(int) is 4

6.7.2.2 Enumeration specifiers
4 Each enumerated type shall be compatible with char, a signed integer type, or an unsigned integer type. The choice of type is implementation-defined, but shall be capable of representing the values of all the members of the enumeration.

so enum type isn't requered to be int.

zg <zg0>
Mon 13 Jun 2011 03:01:44 PM UTC, comment #4:

enums have to be ints but the size of the int is implementation defined. I've seen an 8-bit compiler implement enums as unsigned chars when the largest member was < 256.

Bill Auerbach <billauerbach>
Mon 13 Jun 2011 09:45:00 AM UTC, comment #3:

Hmm..., while I don't know the standard by heart here, I do know that my IAR M16C compiler does implement enums as u8_t if the values fit in. And I was happy more than once that the compiler saved me from converting from enum to u8_t/defines.

However, when writing the MEM_USE_POOLS code, I didn't think of that possibility. So while this might not be strict standard, I think it's a common optimization for embedded compilers.

And since the change on our side is pretty small (just some MEM_ALIGN() macros), I think we can fix this.

Simon Goldschmidt <goldsimon>
Project AdministratorIn charge of this item.
Mon 13 Jun 2011 09:35:16 AM UTC, comment #2:

What is sizeof(int) on your system? I would expect sizeof(struct memp_malloc_helper) to be the same as sizeof(int) as the memp_malloc_helper just contains an enum type, and ANSI C says enums are represented as int.

Kieran Mansley <kieranm>
Project Administrator
Sun 12 Jun 2011 12:24:34 PM UTC, comment #1:

I use gcc 4.5.1 with arm-eabi target.
compiler options: -O2 -march=armv5te -mtune=arm946e-s
sizeof(struct memp_malloc_helper)=1;
so mem_malloc returns something like 0x41ef5.

zg <zg0>
Sun 12 Jun 2011 12:16:51 PM UTC, original submission:
zg <zg0>

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by billauerbach (Posted a comment)
  • -unavailable- added by goldsimon (Posted a comment)
  • -unavailable- added by kieranm (Posted a comment)
  • -unavailable- added by zg0 (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sun 26 Jun 2011 05:33:35 PM UTCgoldsimonStatusNone=>Fixed
      Assigned toNone=>goldsimon
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1