public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/52534] New: gcc doesn't detect incorrect expression in call to va_start
@ 2012-03-08 21:14 mib.bugzilla at gmail dot com
  2012-03-12 14:10 ` [Bug c/52534] " rguenth at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: mib.bugzilla at gmail dot com @ 2012-03-08 21:14 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52534

             Bug #: 52534
           Summary: gcc doesn't detect incorrect expression in call to
                    va_start
    Classification: Unclassified
           Product: gcc
           Version: 4.5.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: mib.bugzilla@gmail.com


The C standard is very clear that the second argument to va_start is a
parameter identifier, not an expression. 

For example,

int maxof(int, ...) ;
void f(void);

int maxof(int n_args, ...){
    register int i;
    int max, a;
    va_list ap;
    va_start(ap, (unsigned int)n_args);
    max = va_arg(ap, int);
    for(i = 2; i <= n_args; i++) {
       if((a = va_arg(ap, int)) > max) max = a;
    }
    va_end(ap);
    return max;
}

Intel compiler finds the bug:
vaarg.c(12): error: incorrect use of va_start
      va_start(ap, (unsigned int)n_args);
      ^


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

end of thread, other threads:[~2024-04-09 11:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-08 21:14 [Bug c/52534] New: gcc doesn't detect incorrect expression in call to va_start mib.bugzilla at gmail dot com
2012-03-12 14:10 ` [Bug c/52534] " rguenth at gcc dot gnu.org
2012-03-15  9:49 ` pinskia at gcc dot gnu.org
2012-03-15 10:04 ` jakub at gcc dot gnu.org
2024-04-09  6:41 ` pinskia at gcc dot gnu.org
2024-04-09 11:06 ` jakub 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).