PC-lint/FlexeLint Output | Reference Manual Explanation | Home Page

            bug651.cpp

1    #include <stdio.h>
2
3    struct { int a[3], b; } w[] = { { 1, 2, 3 }, 2 };
4
5    int main()
6        {
7        printf( "w[0].b = %d\n", w[0].b );
8        return 0;
9        }

The programmer expected to print the value '2'. Instead he got '0'. How come?


bug651.cpp lint Output

--- Module:   bug651.c
struct { int a[3], b; } w[] = { { 1, 2, 3 }, 2 };
                                  ^
bug651.c(3) : Warning 651: Potentially confusing initializer

struct { int a[3], b; } w[] = { { 1, 2, 3 }, 2 };
                                          ^
bug651.c(3) : Info 785: Too few initializers for aggregate

struct { int a[3], b; } w[] = { { 1, 2, 3 }, 2 };
                                               ^
bug651.c(3) : Info 785: Too few initializers for aggregate

struct { int a[3], b; } w[] = { { 1, 2, 3 }, 2 };
                                               ^
bug651.c(3) : Info 785: Too few initializers for aggregate


    --- Wrap-up for Module: bug651.c

Info 754: local structure member 'a' (line 3, file bug651.c) not referenced


Reference Manual Explanation

 
651   Potentially confusing initializer  -- An initializer for  a
      complex  aggregate  is being processed that  contains  some
      subaggregates  that are bracketed and some  that  are  not.
      ANSI  recommends either "minimally bracketed"  initializers
      in  which there are no interior braces or "fully bracketed"
      initializers   in   which  all  interior   aggregates   are
      bracketed.


Previous Bug - Bug #603 - September 2001

PC-lint/FlexeLint - Product Overview

Home | Contact | Order

PC-lint and FlexeLint are trademarks of Gimpel Software
Copyright © 2003, Gimpel Software