lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 100+ warnings and some cosmetics along the way (issue1724041)


From: Jan Nieuwenhuizen
Subject: Re: 100+ warnings and some cosmetics along the way (issue1724041)
Date: Thu, 17 Jun 2010 11:47:11 +0200

Op donderdag 17-06-2010 om 00:41 uur [tijdzone -0300], schreef Han-Wen
Nienhuys:

> > * Why are all the casts there?

casts are mostly bad and often indication that something is wrong.

>  It is probably an easier fix to change vsize to be an int again.

This may be easiest fix and probably wrong.  The vsize fix was
chosen to identify problem areas and work to be done: it was an
easy way of saying:we moved from flower arrays to std::vector,
change to size_t or something as appropriate.

Possibly I'm rambling and it's more useful to discuss actual
code than ideas.  Are we thinking of using INTs for vector
sizes as in the code below?  If so, why would that work?

Greetings,
Jan.

    #include <limits.h>
    #include <stdio.h>
    #include <vector>

    using std::vector;

    int
    main ()
    {
      vector<short> x (INT_MAX+1ULL);
      int size_i = x.size ();
      size_t size_u = x.size ();
      printf ("i:%d, z:%zd\n", size_i, size_u);
      for (int i = 0; i < size_i; i++)
        return 0;
      printf ("FAIL!\n");
      return 1;
    }

    $ g++     v.cc   -o v -Woverloaded-virtual -fno-strict-aliasing  -g -fwrapv 
-Wno-pmf-conversions -W -Wall -Wconversion 
    v.cc: In function ‘int main()’:
    v.cc:11: warning: conversion to ‘int’ from ‘size_t’ may alter its value
    10:03:16 address@hidden:~/src/c++
    $ ./v
    i:-2147483648, z:2147483648
    FAIL!
    [1]10:04:16 address@hidden:~/src/c++


-- 
Jan Nieuwenhuizen <address@hidden> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyOfSource.com | Avatar®  http://AvatarAcademy.nl  





reply via email to

[Prev in Thread] Current Thread [Next in Thread]