public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/99331] New: -Wconversion false-positive in immidiate context
@ 2021-03-01 18:43 nok.raven at gmail dot com
2021-03-01 18:47 ` [Bug c++/99331] [8/9/10/11 Regression] -Wconversion false-positive in immediate context mpolacek at gcc dot gnu.org
` (10 more replies)
0 siblings, 11 replies; 12+ messages in thread
From: nok.raven at gmail dot com @ 2021-03-01 18:43 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99331
Bug ID: 99331
Summary: -Wconversion false-positive in immidiate context
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Keywords: diagnostic
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: nok.raven at gmail dot com
Target Milestone: ---
template <int N> struct X {};
template <class T> X<sizeof(T)> foo();
g++ -Wconversion -Werror src.cpp
<source>:2:22: error: conversion from 'long unsigned int' to 'int' may change
value [-Werror=conversion]
2 | template <class T> X<sizeof(T)> foo();
| ^~~~~~~~~
https://godbolt.org/z/d16WhG
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/99331] [8/9/10/11 Regression] -Wconversion false-positive in immediate context
2021-03-01 18:43 [Bug c++/99331] New: -Wconversion false-positive in immidiate context nok.raven at gmail dot com
@ 2021-03-01 18:47 ` mpolacek at gcc dot gnu.org
2021-03-01 18:50 ` mpolacek at gcc dot gnu.org
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-03-01 18:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99331
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mpolacek at gcc dot gnu.org
Ever confirmed|0 |1
Summary|-Wconversion false-positive |[8/9/10/11 Regression]
|in immidiate context |-Wconversion false-positive
| |in immediate context
Target Milestone|--- |8.5
Priority|P3 |P2
Last reconfirmed| |2021-03-01
Status|UNCONFIRMED |NEW
--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Confirmed. Started in GCC 7.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/99331] [8/9/10/11 Regression] -Wconversion false-positive in immediate context
2021-03-01 18:43 [Bug c++/99331] New: -Wconversion false-positive in immidiate context nok.raven at gmail dot com
2021-03-01 18:47 ` [Bug c++/99331] [8/9/10/11 Regression] -Wconversion false-positive in immediate context mpolacek at gcc dot gnu.org
@ 2021-03-01 18:50 ` mpolacek at gcc dot gnu.org
2021-03-01 18:54 ` nok.raven at gmail dot com
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-03-01 18:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99331
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |mpolacek at gcc dot gnu.org
--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Started with
commit 16b61424dd309f61326f577a6deb8487c6c1f291
Author: Jason Merrill <jason@redhat.com>
Date: Fri Oct 21 15:45:45 2016 -0400
re PR c++/77656 (64-bit integral template parameter gets incorrectly sized
as 32-bits)
PR c++/77656
* pt.c (convert_template_argument): Call convert_nontype_argument
on value-dependent but not type-dependent arguments.
(convert_nontype_argument): Handle value-dependent arguments.
(canonicalize_expr_argument): New.
(deducible_expression, unify): Skip CONVERT_EXPR.
* error.c (dump_template_argument): Likewise.
* mangle.c (write_expression): Likewise.
From-SVN: r241425
think I'll have a look at this myself, though.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/99331] [8/9/10/11 Regression] -Wconversion false-positive in immediate context
2021-03-01 18:43 [Bug c++/99331] New: -Wconversion false-positive in immidiate context nok.raven at gmail dot com
2021-03-01 18:47 ` [Bug c++/99331] [8/9/10/11 Regression] -Wconversion false-positive in immediate context mpolacek at gcc dot gnu.org
2021-03-01 18:50 ` mpolacek at gcc dot gnu.org
@ 2021-03-01 18:54 ` nok.raven at gmail dot com
2021-03-02 22:06 ` mpolacek at gcc dot gnu.org
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: nok.raven at gmail dot com @ 2021-03-01 18:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99331
--- Comment #3 from Nikita Kniazev <nok.raven at gmail dot com> ---
This one most likely has the same root problem:
template <int N> struct X {};
template <typename T>
struct foo { using t = X<sizeof(T)>; };
<source>:3:26: error: conversion from 'long unsigned int' to 'int' may change
value [-Werror=conversion]
3 | struct foo { using t = X<sizeof(T)>; };
| ^~~~~~~~~
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/99331] [8/9/10/11 Regression] -Wconversion false-positive in immediate context
2021-03-01 18:43 [Bug c++/99331] New: -Wconversion false-positive in immidiate context nok.raven at gmail dot com
` (2 preceding siblings ...)
2021-03-01 18:54 ` nok.raven at gmail dot com
@ 2021-03-02 22:06 ` mpolacek at gcc dot gnu.org
2021-03-25 18:58 ` cvs-commit at gcc dot gnu.org
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-03-02 22:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99331
--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
This is caused by this change:
@@ -7278,7 +7306,7 @@ convert_template_argument (tree parm,
val = error_mark_node;
}
}
- else if (!dependent_template_arg_p (orig_arg)
+ else if (!type_dependent_expression_p (orig_arg)
&& !uses_template_parms (t))
/* We used to call digest_init here. However, digest_init
will report errors, which we don't want when complain
Here orig_arg is SIZEOF_EXPR<T>; dependent_template_arg_p (orig_arg) was true,
but type_dependent_expression_p (orig_arg) is false so we warn in
convert_nontype_argument.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/99331] [8/9/10/11 Regression] -Wconversion false-positive in immediate context
2021-03-01 18:43 [Bug c++/99331] New: -Wconversion false-positive in immidiate context nok.raven at gmail dot com
` (3 preceding siblings ...)
2021-03-02 22:06 ` mpolacek at gcc dot gnu.org
@ 2021-03-25 18:58 ` cvs-commit at gcc dot gnu.org
2021-03-25 19:05 ` [Bug c++/99331] [8/9/10 " mpolacek at gcc dot gnu.org
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-03-25 18:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99331
--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:
https://gcc.gnu.org/g:9efd72d28956eb79c7fca38e3c959733a3bb25bb
commit r11-7833-g9efd72d28956eb79c7fca38e3c959733a3bb25bb
Author: Marek Polacek <polacek@redhat.com>
Date: Thu Mar 4 20:20:40 2021 -0500
c++: -Wconversion vs value-dependent expressions [PR99331]
This PR complains that we issue a -Wconversion warning in
template <int N> struct X {};
template <class T> X<sizeof(T)> foo();
saying "conversion from 'long unsigned int' to 'int' may change value".
While it's not technically wrong, I suspect -Wconversion warnings aren't
all that useful for value-dependent expressions. So this patch disables
them. This is a regression that started with r241425:
@@ -7278,7 +7306,7 @@ convert_template_argument (tree parm,
val = error_mark_node;
}
}
- else if (!dependent_template_arg_p (orig_arg)
+ else if (!type_dependent_expression_p (orig_arg)
&& !uses_template_parms (t))
/* We used to call digest_init here. However, digest_init
will report errors, which we don't want when complain
Here orig_arg is SIZEOF_EXPR<T>; dependent_template_arg_p (orig_arg) was
true, but type_dependent_expression_p (orig_arg) is false so we warn in
convert_nontype_argument.
gcc/cp/ChangeLog:
PR c++/99331
* call.c (build_converted_constant_expr_internal): Don't emit
-Wconversion warnings.
gcc/testsuite/ChangeLog:
PR c++/99331
* g++.dg/warn/Wconversion5.C: New test.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/99331] [8/9/10 Regression] -Wconversion false-positive in immediate context
2021-03-01 18:43 [Bug c++/99331] New: -Wconversion false-positive in immidiate context nok.raven at gmail dot com
` (4 preceding siblings ...)
2021-03-25 18:58 ` cvs-commit at gcc dot gnu.org
@ 2021-03-25 19:05 ` mpolacek at gcc dot gnu.org
2021-03-26 12:58 ` nok.raven at gmail dot com
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-03-25 19:05 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99331
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[8/9/10/11 Regression] |[8/9/10 Regression]
|-Wconversion false-positive |-Wconversion false-positive
|in immediate context |in immediate context
--- Comment #6 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed on trunk thus far.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/99331] [8/9/10 Regression] -Wconversion false-positive in immediate context
2021-03-01 18:43 [Bug c++/99331] New: -Wconversion false-positive in immidiate context nok.raven at gmail dot com
` (5 preceding siblings ...)
2021-03-25 19:05 ` [Bug c++/99331] [8/9/10 " mpolacek at gcc dot gnu.org
@ 2021-03-26 12:58 ` nok.raven at gmail dot com
2021-03-26 15:19 ` mpolacek at gcc dot gnu.org
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: nok.raven at gmail dot com @ 2021-03-26 12:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99331
--- Comment #7 from Nikita Kniazev <nok.raven at gmail dot com> ---
The fix silenced the true warning (though it was saying 'may') in these:
template <char N> struct X {};
template <class T> X<sizeof(T)> foo();
int x = sizeof(foo<char[512]>());
template <char N> struct X {};
template <typename T>
struct foo { using t = X<sizeof(T)>; };
foo<char[512]> x;
Should I post this as a separate issue?
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/99331] [8/9/10 Regression] -Wconversion false-positive in immediate context
2021-03-01 18:43 [Bug c++/99331] New: -Wconversion false-positive in immidiate context nok.raven at gmail dot com
` (6 preceding siblings ...)
2021-03-26 12:58 ` nok.raven at gmail dot com
@ 2021-03-26 15:19 ` mpolacek at gcc dot gnu.org
2021-04-09 22:44 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-03-26 15:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99331
--- Comment #8 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Yeah, that's expected (but it's a bug!):
https://gcc.gnu.org/pipermail/gcc-patches/2021-March/566449.html
Opening a separate issue would be nice, thanks.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/99331] [8/9/10 Regression] -Wconversion false-positive in immediate context
2021-03-01 18:43 [Bug c++/99331] New: -Wconversion false-positive in immidiate context nok.raven at gmail dot com
` (7 preceding siblings ...)
2021-03-26 15:19 ` mpolacek at gcc dot gnu.org
@ 2021-04-09 22:44 ` cvs-commit at gcc dot gnu.org
2021-04-09 22:44 ` mpolacek at gcc dot gnu.org
2022-03-14 12:54 ` ppalka at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-04-09 22:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99331
--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Marek Polacek
<mpolacek@gcc.gnu.org>:
https://gcc.gnu.org/g:b281edd801018ed703ce7bb0d49fef59ff8cef8b
commit r10-9688-gb281edd801018ed703ce7bb0d49fef59ff8cef8b
Author: Marek Polacek <polacek@redhat.com>
Date: Thu Mar 4 20:20:40 2021 -0500
c++: -Wconversion vs value-dependent expressions [PR99331]
This PR complains that we issue a -Wconversion warning in
template <int N> struct X {};
template <class T> X<sizeof(T)> foo();
saying "conversion from 'long unsigned int' to 'int' may change value".
While it's not technically wrong, I suspect -Wconversion warnings aren't
all that useful for value-dependent expressions. So this patch disables
them. This is a regression that started with r241425:
@@ -7278,7 +7306,7 @@ convert_template_argument (tree parm,
val = error_mark_node;
}
}
- else if (!dependent_template_arg_p (orig_arg)
+ else if (!type_dependent_expression_p (orig_arg)
&& !uses_template_parms (t))
/* We used to call digest_init here. However, digest_init
will report errors, which we don't want when complain
Here orig_arg is SIZEOF_EXPR<T>; dependent_template_arg_p (orig_arg) was
true, but type_dependent_expression_p (orig_arg) is false so we warn in
convert_nontype_argument.
gcc/cp/ChangeLog:
PR c++/99331
* call.c (build_converted_constant_expr_internal): Don't emit
-Wconversion warnings.
gcc/testsuite/ChangeLog:
PR c++/99331
* g++.dg/warn/Wconversion5.C: New test.
(cherry picked from commit 9efd72d28956eb79c7fca38e3c959733a3bb25bb)
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/99331] [8/9/10 Regression] -Wconversion false-positive in immediate context
2021-03-01 18:43 [Bug c++/99331] New: -Wconversion false-positive in immidiate context nok.raven at gmail dot com
` (8 preceding siblings ...)
2021-04-09 22:44 ` cvs-commit at gcc dot gnu.org
@ 2021-04-09 22:44 ` mpolacek at gcc dot gnu.org
2022-03-14 12:54 ` ppalka at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2021-04-09 22:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99331
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #10 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed in GCC 10.4 too.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/99331] [8/9/10 Regression] -Wconversion false-positive in immediate context
2021-03-01 18:43 [Bug c++/99331] New: -Wconversion false-positive in immidiate context nok.raven at gmail dot com
` (9 preceding siblings ...)
2021-04-09 22:44 ` mpolacek at gcc dot gnu.org
@ 2022-03-14 12:54 ` ppalka at gcc dot gnu.org
10 siblings, 0 replies; 12+ messages in thread
From: ppalka at gcc dot gnu.org @ 2022-03-14 12:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99331
Patrick Palka <ppalka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jens.maurer at gmx dot net
--- Comment #11 from Patrick Palka <ppalka at gcc dot gnu.org> ---
*** Bug 80601 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2022-03-14 12:54 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-01 18:43 [Bug c++/99331] New: -Wconversion false-positive in immidiate context nok.raven at gmail dot com
2021-03-01 18:47 ` [Bug c++/99331] [8/9/10/11 Regression] -Wconversion false-positive in immediate context mpolacek at gcc dot gnu.org
2021-03-01 18:50 ` mpolacek at gcc dot gnu.org
2021-03-01 18:54 ` nok.raven at gmail dot com
2021-03-02 22:06 ` mpolacek at gcc dot gnu.org
2021-03-25 18:58 ` cvs-commit at gcc dot gnu.org
2021-03-25 19:05 ` [Bug c++/99331] [8/9/10 " mpolacek at gcc dot gnu.org
2021-03-26 12:58 ` nok.raven at gmail dot com
2021-03-26 15:19 ` mpolacek at gcc dot gnu.org
2021-04-09 22:44 ` cvs-commit at gcc dot gnu.org
2021-04-09 22:44 ` mpolacek at gcc dot gnu.org
2022-03-14 12:54 ` ppalka at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).