public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/61951] New: -wExtra switch produce warning: parameter 'ptr' set but not used [-Wunused-but-set-parameter]
@ 2014-07-29 15:13 moblaza at gmail dot com
  2014-09-17 16:42 ` [Bug c++/61951] -Wextra " paolo.carlini at oracle dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: moblaza at gmail dot com @ 2014-07-29 15:13 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61951

            Bug ID: 61951
           Summary: -wExtra switch produce warning: parameter 'ptr' set
                    but not used [-Wunused-but-set-parameter]
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: moblaza at gmail dot com

Created attachment 33204
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33204&action=edit
program with this code example

Hello! Il write code example with lambda expression, with operator new class
allocation, and g++ produce warning:

D:\workspace\gcc_test1\main.cpp:33:67: warning: parameter 'ptr' set but not
used [-Wunused-but-set-parameter]
                 std::for_each(ref.begin(), ref.end(), [](Base* ptr){

but after allocation, lambda parameter is used also in lambda expression with
for_each algorithm. See attached code.

PS.
My: gcc version 4.8.1 (rev5, Built by MinGW-W64 project)


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/61951] -Wextra switch produce warning: parameter 'ptr' set but not used [-Wunused-but-set-parameter]
  2014-07-29 15:13 [Bug c++/61951] New: -wExtra switch produce warning: parameter 'ptr' set but not used [-Wunused-but-set-parameter] moblaza at gmail dot com
@ 2014-09-17 16:42 ` paolo.carlini at oracle dot com
  2014-09-17 16:56 ` jakub at gcc dot gnu.org
  2014-09-19  9:43 ` paolo.carlini at oracle dot com
  2 siblings, 0 replies; 4+ messages in thread
From: paolo.carlini at oracle dot com @ 2014-09-17 16:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61951

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-09-17
                 CC|                            |jakub at redhat dot com
            Summary|-wExtra switch produce      |-Wextra switch produce
                   |warning: parameter 'ptr'    |warning: parameter 'ptr'
                   |set but not used            |set but not used
                   |[-Wunused-but-set-parameter |[-Wunused-but-set-parameter
                   |]                           |]
     Ever confirmed|0                           |1

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Maybe Jakub is willing to have a look. Otherwise I may come to it.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/61951] -Wextra switch produce warning: parameter 'ptr' set but not used [-Wunused-but-set-parameter]
  2014-07-29 15:13 [Bug c++/61951] New: -wExtra switch produce warning: parameter 'ptr' set but not used [-Wunused-but-set-parameter] moblaza at gmail dot com
  2014-09-17 16:42 ` [Bug c++/61951] -Wextra " paolo.carlini at oracle dot com
@ 2014-09-17 16:56 ` jakub at gcc dot gnu.org
  2014-09-19  9:43 ` paolo.carlini at oracle dot com
  2 siblings, 0 replies; 4+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-09-17 16:56 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61951

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Is there anything wrong on the warning though?

[](Base* ptr){ ptr = new Deliv(); }

I think ptr here is lambda parameter, does it behave any different from
parameter to any other function?
void foo (Base* ptr) { ptr = new Deliv(); }
warns about parameter 'ptr' set but not used intentionally, so why shouldn't it
we warn about it in the lambda?  Doesn't the lambda just leak memory and not
actually store the pointer anywhere (it stores it into the parameter which is
never used)?


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c++/61951] -Wextra switch produce warning: parameter 'ptr' set but not used [-Wunused-but-set-parameter]
  2014-07-29 15:13 [Bug c++/61951] New: -wExtra switch produce warning: parameter 'ptr' set but not used [-Wunused-but-set-parameter] moblaza at gmail dot com
  2014-09-17 16:42 ` [Bug c++/61951] -Wextra " paolo.carlini at oracle dot com
  2014-09-17 16:56 ` jakub at gcc dot gnu.org
@ 2014-09-19  9:43 ` paolo.carlini at oracle dot com
  2 siblings, 0 replies; 4+ messages in thread
From: paolo.carlini at oracle dot com @ 2014-09-19  9:43 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61951

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |INVALID

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Thanks Jakub. Now that I notice that specific line and you confirmed that the
warning is intentional in the non-lambda case, I believe we can close the bug.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-09-19  9:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-29 15:13 [Bug c++/61951] New: -wExtra switch produce warning: parameter 'ptr' set but not used [-Wunused-but-set-parameter] moblaza at gmail dot com
2014-09-17 16:42 ` [Bug c++/61951] -Wextra " paolo.carlini at oracle dot com
2014-09-17 16:56 ` jakub at gcc dot gnu.org
2014-09-19  9:43 ` paolo.carlini at oracle dot com

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).