13 years, 5 months ago
(2011-07-16 00:59:56 UTC)
#3
http://codereview.appspot.com/4731042/diff/1001/test/Sema/conditional-expr.c
File test/Sema/conditional-expr.c (right):
http://codereview.appspot.com/4731042/diff/1001/test/Sema/conditional-expr.c#...
test/Sema/conditional-expr.c:54: test0 = test0 ? EVal : (int) test0; //
expected-warning {{operand of ? changes signedness: 'int' to 'unsigned long'}}
On 2011/07/16 00:44:26, rtrieu wrote:
> On 2011/07/15 22:28:37, chandlerc wrote:
> > Why is this now warning?
>
> test0 is unsigned. Both EVal and (int) test0 are signed integers. When
either
> one is assigned to test0, they must be sign converted, and thus get warned on.
Maybe get a signed value to assign to? That way its more clear that the ?:
doesn't warn.
Also, this diagnostic is really confusing -- it makes it sound like only one of
the operands would be subject to this conversion when they both would... but
that is likely an orthogonal issue...
13 years, 5 months ago
(2011-07-19 03:58:49 UTC)
#4
http://codereview.appspot.com/4731042/diff/1001/test/Sema/conditional-expr.c
File test/Sema/conditional-expr.c (right):
http://codereview.appspot.com/4731042/diff/1001/test/Sema/conditional-expr.c#...
test/Sema/conditional-expr.c:54: test0 = test0 ? EVal : (int) test0; //
expected-warning {{operand of ? changes signedness: 'int' to 'unsigned long'}}
On 2011/07/16 00:59:56, chandlerc wrote:
> On 2011/07/16 00:44:26, rtrieu wrote:
> > On 2011/07/15 22:28:37, chandlerc wrote:
> > > Why is this now warning?
> >
> > test0 is unsigned. Both EVal and (int) test0 are signed integers. When
> either
> > one is assigned to test0, they must be sign converted, and thus get warned
on.
>
> Maybe get a signed value to assign to? That way its more clear that the ?:
> doesn't warn.
>
> Also, this diagnostic is really confusing -- it makes it sound like only one
of
> the operands would be subject to this conversion when they both would... but
> that is likely an orthogonal issue...
Added a comment to clarify the warning reason. Moved the related test cases
together.
13 years, 5 months ago
(2011-07-19 08:03:05 UTC)
#5
http://codereview.appspot.com/4731042/diff/1001/test/Sema/conditional-expr.c
File test/Sema/conditional-expr.c (right):
http://codereview.appspot.com/4731042/diff/1001/test/Sema/conditional-expr.c#...
test/Sema/conditional-expr.c:54: test0 = test0 ? EVal : (int) test0; //
expected-warning {{operand of ? changes signedness: 'int' to 'unsigned long'}}
On 2011/07/19 03:58:50, rtrieu wrote:
> On 2011/07/16 00:59:56, chandlerc wrote:
> > On 2011/07/16 00:44:26, rtrieu wrote:
> > > On 2011/07/15 22:28:37, chandlerc wrote:
> > > > Why is this now warning?
> > >
> > > test0 is unsigned. Both EVal and (int) test0 are signed integers. When
> > either
> > > one is assigned to test0, they must be sign converted, and thus get warned
> on.
> >
> > Maybe get a signed value to assign to? That way its more clear that the ?:
> > doesn't warn.
> >
> > Also, this diagnostic is really confusing -- it makes it sound like only one
> of
> > the operands would be subject to this conversion when they both would... but
> > that is likely an orthogonal issue...
>
> Added a comment to clarify the warning reason. Moved the related test cases
> together.
I like the grouping, but why not just move 'test1's declaration up from line 61
to line 57, and assign to test1 which is signed? Then there won't be any warning
to explain...
13 years, 5 months ago
(2011-07-19 19:40:36 UTC)
#6
http://codereview.appspot.com/4731042/diff/1001/test/Sema/conditional-expr.c
File test/Sema/conditional-expr.c (right):
http://codereview.appspot.com/4731042/diff/1001/test/Sema/conditional-expr.c#...
test/Sema/conditional-expr.c:54: test0 = test0 ? EVal : (int) test0; //
expected-warning {{operand of ? changes signedness: 'int' to 'unsigned long'}}
On 2011/07/19 08:03:05, chandlerc wrote:
> On 2011/07/19 03:58:50, rtrieu wrote:
> > On 2011/07/16 00:59:56, chandlerc wrote:
> > > On 2011/07/16 00:44:26, rtrieu wrote:
> > > > On 2011/07/15 22:28:37, chandlerc wrote:
> > > > > Why is this now warning?
> > > >
> > > > test0 is unsigned. Both EVal and (int) test0 are signed integers. When
> > > either
> > > > one is assigned to test0, they must be sign converted, and thus get
warned
> > on.
> > >
> > > Maybe get a signed value to assign to? That way its more clear that the ?:
> > > doesn't warn.
> > >
> > > Also, this diagnostic is really confusing -- it makes it sound like only
one
> > of
> > > the operands would be subject to this conversion when they both would...
but
> > > that is likely an orthogonal issue...
> >
> > Added a comment to clarify the warning reason. Moved the related test cases
> > together.
>
> I like the grouping, but why not just move 'test1's declaration up from line
61
> to line 57, and assign to test1 which is signed? Then there won't be any
warning
> to explain...
Done.
Issue 4731042: Remove check for mixed signs on conditional operands from -Wsign-compare
(Closed)
Created 13 years, 5 months ago by rtrieu
Modified 13 years, 5 months ago
Reviewers: chandlerc
Base URL: https://llvm.org/svn/llvm-project/cfe/trunk/
Comments: 12