Bug 57480 - struct with a va_list considered as non-POD
Summary: struct with a va_list considered as non-POD
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.7.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid, wrong-code
Depends on:
Blocks:
 
Reported: 2013-05-31 08:43 UTC by Roman Tsisyk
Modified: 2021-08-12 22:16 UTC (History)
2 users (show)

See Also:
Host:
Target: x86_64-linux-gnu aarch64-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed: 2021-08-11 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Roman Tsisyk 2013-05-31 08:43:07 UTC
C++ frontend marks structs with va_list as non-POD.
This problem is probably related to 31488.

roman@work:~$ cat va_list_is_not_pod.cc 
#include <stdarg.h>
#include <type_traits>

struct fiber {
    va_list va;
};

int
main(int argc, char *argv[])
{
    static_assert(std::is_pod<struct fiber>::value, "Should be POD");
}


roman@work:~$ g++ -std=c++11 va_list_is_not_pod.cc -o test
va_list_is_not_pod.cc: In function ‘int main(int, char**)’:
va_list_is_not_pod.cc:11:5: error: static assertion failed: Should be POD

gcc version 4.7.2 (Debian 4.7.2-5)
Comment 1 Daniel Krügler 2013-05-31 10:45:28 UTC
Seems to be fixed in gcc  4.9.0 20130519 (experimental)
Comment 2 Jonathan Wakely 2013-05-31 10:53:54 UTC
Surely this depends on whether is_pod<va_list> is true, and is that required, or is it unspecified?

I think this should always pass though:

static_assert(is_pod<fiber>::value == is_pod<va_list>::value, "same PODness");
Comment 3 Daniel Krügler 2013-05-31 11:06:17 UTC
(In reply to Jonathan Wakely from comment #2)
My interprettaion is that the standard does not say anything about that (I think I had once a similar question in regard to another type from the C Library). I suspect that this could be a C++ Library defect. But I would argue that here the intention is arg_list to be a pod based on [support.runtime] p2:

"The contents of these headers are the same as the Standard C library headers [..] <stdarg.h>, [..], respectively, with the following changes: [..]"

I cannot deduce anything from the changes that could be interpreted in a way explaining such a difference. My guess is that the is_pod trait was not fully implemented in gcc 4.7.2, was it?
Comment 4 Roman Tsisyk 2013-05-31 12:10:29 UTC
I use offsetof on this structure and C++ produces a warning about POD data type.
std::is_pod is not so important here.
I temporary add -Wno-invalid-offsetof to my code.
Comment 5 Andrew Pinski 2021-08-11 21:18:25 UTC
This is still an issue.

Confirmed.