17.07.2020 18:35, Alex Peshkoff via Firebird-devel wrote:
Not sure about VC - but fresh enough (at least 8.x) gcc often produces the 
following warning (exact reason certainly differs):

/usr/home/firebird/B3_0_Release/src/jrd/trace/../../jrd/trace/../../dsql/../jrd/val.h:154:39: warning: ‘void* memset(void*, int, size_t)’ clearing an object of non-trivial type ‘struct Jrd::impure_value’; use assignment or value-initialization instead [-Wclass-memaccess]
     memset(&*impure, 0, sizeof(*impure));

  In this particular case I see no reason for (ugly, imho) "&*" usage. More, the
whole "for" loop is not required as fmt_defaults.resize(fmt_count) above already
zeroed all the memory allocated. Funny is that fmt_desc is allocated and resized
in exactly same way but not zeroed explicitly as fmt_defaults.

In master it's turned off using gcc switch, but in 3.0 - one can easily see it.

  You may see all disabled warnings at src\include\gen\autoconfig_msvc.h.
I failed to find similar warning there. More, when compiling just jrd.cpp with
-Wall there is no warnings at all for fb3\MSVC2013 and a lot of warnings for
fb4\MSVC2017 - but nothing is like your sample.

I think that using switches to turn off warnings is not best practice (warnings in general are useful) and should be used only when there is no better solution.

  Agree

For this particular case the following solution may be used instead:
     memset((void*)&*impure, 0, sizeof(*impure));

  Looks even more ugly than before :(

i.e. explicit C-cast. It's absolutely safe cause it's anyway done when callin 
mem* functions.

Do you agree it's better approach? If nobody agrues against I'm going to 
perform sources review in the middle of next week.

  My opinion is that we should find balance between code readability and 
following
more and more strict (not always for good reason) compiler requirements. Of 
course,
not sacrificing code safety and correctness.

  Also, I don't think we should make mass cleanups in stable (v3) and, 
probably, in
almost stable (v4) code branches. Probably would be better to do it in v5, if 
necessary.

  Again - this is just my opinion.

Regards,
Vlad



Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to