public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/103920] New: No warning for large structs passed by value ?
@ 2022-01-05 16:48 dcb314 at hotmail dot com
  2022-01-05 17:15 ` [Bug c/103920] " redi at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: dcb314 at hotmail dot com @ 2022-01-05 16:48 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 103920
           Summary: No warning for large structs passed by value ?
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dcb314 at hotmail dot com
  Target Milestone: ---

For the following code:

$ more jan5c.cc

struct S
{
        long a;
        long b;
        long c;
        long d;
        long a2;
        long b2;
        long c2;
        long d2;
};

void f1( const S s);
void f2( S s);

gcc has not a lot to say:

$ /home/dcb/gcc/results/bin/gcc -c -O2 -Wall -Wextra -pedantic jan5c.cc
$

cppcheck does a slightly better job:

$ /home/dcb/cppcheck/trunk.git/cppcheck --enable=all jan5c.cc
jan5c.cc:14:18: performance: Function parameter 's' should be passed by const
reference. [passedByValue]
void f1( const S s);
                 ^
Also, clang-13 doesn't say anything. 

Judgement call, but "large" might mean four words or more. 

Example code derived from code in the Linux kernel, so even kernel programmers
do this kind of thing in practice.

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

end of thread, other threads:[~2022-02-04  8:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-05 16:48 [Bug c/103920] New: No warning for large structs passed by value ? dcb314 at hotmail dot com
2022-01-05 17:15 ` [Bug c/103920] " redi at gcc dot gnu.org
2022-01-05 20:05 ` pinskia at gcc dot gnu.org
2022-01-10 10:34 ` rguenth at gcc dot gnu.org
2022-02-04  8:08 ` egallager 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).