[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH] fix potentially undefined operation warning

From: Branko Čibej <brane_at_wandisco.com>
Date: Thu, 15 May 2014 07:49:08 -0700

On 10.05.2014 05:26, Andreas Stieger wrote:
> Hello,
>
> I found a compiler warning in trunk on a potentially undefined operation
> when using an increment operator on a variable referenced in the same
> expression. This is on gcc 4.3.4, does not happen in gcc 4.7 and up.
> Treated as an error in some build configurations.
>
> subversion/libsvn_fs_fs/id.c: In function 'txn_id_parse':
> subversion/libsvn_fs_fs/id.c:98: warning: operation on 'data' may be
> undefined
>
> subversion/libsvn_fs_fs/transaction.c: In function 'read_next_ids':
> subversion/libsvn_fs_fs/transaction.c:1300: warning: operation on 'str'
> may be undefined
>
> subversion/libsvn_fs_x/transaction.c: In function 'read_next_ids':
> subversion/libsvn_fs_x/transaction.c:1354: warning: operation on 'str'
> may be undefined
>
> The attached patch fixes this, please review.

Good catch, the result of these operations is indeed undefined,
according to the C standard.
However, I don't know if your fix is correct ... the other
interpretation is:

        foo(&data, data + 1);
        ++data;

The author of this code should have a look and decide which
interpretation he meant.

-- Brane

-- 
Branko Čibej | Director of Subversion
WANdisco // Non-Stop Data
e. brane_at_wandisco.com
Received on 2014-05-17 04:14:53 CEST

This is an archived mail posted to the Subversion Dev mailing list.