[Qt-creator] Clang Code Model: add -Wno-padded

Andrzej Telszewski atelszewski at gmail.com
Thu Mar 3 22:22:22 CET 2016


On 03/03/16 21:55, Bubke Marco wrote:
> You don't have to silence the warning,  it is a warning not a error. And you can  change that in the settings.
>
> I think it quite informative that
>
> bool x, y,  z;
> int w;
> char c;
>
> Is not optimal. If you don't like that disable it in the settings.

I do think that having this kind of information is useful, but in my 
opinion -Wno-padded should be default, and turning on the warning should 
be left to those who need it. I personally added -Wno-padded to the 
clang model settings.

Say you have a struct like that:
struct nopad
{
   bool flag1;
   bool flag2;
};

It is perfectly fine structure and you don't have to pad it, yet you get 
the warning. I would understand, if the warning told you to re-arrange 
the members, but it simply warns you about what is the default compiler 
behavior, that it will add 2 or 6 bytes of padding. This has been the 
default compiler behavior for ages, so I don't see the point of giving 
the warning by default;) In addition, the padding depends on the 
architecture you're compiling for, so you would have to take it into 
account.

I'm not against the warning, I'm just saying it shouldn't be enabled by 
default.

My real structure is like that:
typedef struct
{
   string name;
   bool can_span;
} info_key_t;

There is nothing sensible I can change to make the warning disappear.

>
> --
> Sent from cellphone, sorry for the typos
>
>
> On March 3, 2016 20:44:28 Andrzej Telszewski <atelszewski at gmail.com> wrote:
>
>> On 03/03/16 20:23, Bubke Marco wrote:
>>> Hi,  we will add more options in 4.0 to the code model,  so you can choose different sets.
>>>
>>> Anyway I find the padding warning quite useful because it shows that your data structures are sub optimal.
>>>
>>
>> Nope, it does not tell you it's suboptimal. It tells you that compiler
>> will add the additional padding/alignment bytes.
>>
>> Having structure with say 3 bool's and nothing more is perfectly fine.
>> In such a case, to silence the warning, I would have to add some dummy
>> fields, which most of the time is not necessary.
>>
>>> --
>>> Sent from cellphone, sorry for the typos
>>>
>>>
>>>
>>> On March 3, 2016 19:30:31 Andrzej Telszewski <atelszewski at gmail.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> Qt Creator: 3.6.0
>>>>
>>>> Could _-Wno-padded_ flag be added to the Clang Code Model flags?
>>>> I don't believe that warning about padding should be the default behavior.
>>>>
>>>> --
>>>> Best regards,
>>>> Andrzej Telszewski
>>>> _______________________________________________
>>>> Qt-creator mailing list
>>>> Qt-creator at qt-project.org
>>>> http://lists.qt-project.org/mailman/listinfo/qt-creator
>>>
>>
>>
>> --
>> Best regards,
>> Andrzej Telszewski
>
> --
> Sent from cellphone, sorry for the typos
> _______________________________________________
> Qt-creator mailing list
> Qt-creator at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/qt-creator
>


-- 
Pozdrawiam,
Best regards,
Andrzej Telszewski



More information about the Qt-creator mailing list