Bug 68907 - bogus warning: right-hand operand of comma expression has no effect on an atomic_int preincrement
Summary: bogus warning: right-hand operand of comma expression has no effect on an ato...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 6.0
: P3 normal
Target Milestone: 5.4
Assignee: Marek Polacek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-12-15 03:39 UTC by Martin Sebor
Modified: 2015-12-15 15:14 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2015-12-15 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Sebor 2015-12-15 03:39:20 UTC
GCC 5.1.0 and current trunk issue the following incorrect warning on the preincrement of an _Atomic variable.

$ cat ~/tmp/t.c && /build/gcc-trunk/gcc/xgcc -B /build/gcc-trunk/gcc -S -Wall -Wextra -o/dev/null ~/tmp/t.c
$ cat ~/tmp/t.c && /build/gcc-trunk/gcc/xgcc -B /build/gcc-trunk/gcc -S -Wall -Wextra -o/dev/null ~/tmp/t.c
typedef _Atomic int AI;

extern AI ai;

void increment (void)
{
    ++ai;
}
/home/remote/msebor/tmp/t.c: In function ‘increment’:
/home/remote/msebor/tmp/t.c:7:5: warning: right-hand operand of comma expression has no effect [-Wunused-value]
     ++ai;
     ^~~~
Comment 1 Marek Polacek 2015-12-15 07:42:54 UTC
I thought I had fixed something similar some time ago...
Comment 2 Marek Polacek 2015-12-15 07:46:42 UTC
GCC 4.9 warns too.
Comment 3 Marek Polacek 2015-12-15 15:14:21 UTC
Author: mpolacek
Date: Tue Dec 15 15:13:49 2015
New Revision: 231656

URL: https://gcc.gnu.org/viewcvs?rev=231656&root=gcc&view=rev
Log:
	PR c/68907
	* c-typeck.c (build_atomic_assign): Set TREE_NO_WARNING on an
	artificial decl.

	* gcc.dg/pr68907.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/pr68907.c
Modified:
    trunk/gcc/c/ChangeLog
    trunk/gcc/c/c-typeck.c
    trunk/gcc/testsuite/ChangeLog
Comment 4 Marek Polacek 2015-12-15 15:14:38 UTC
Fixed.