This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: has_trivial_destructor improvable?


From: Jonathan Wakely [mailto:jwakely.gcc@gmail.com] 

> N.B. I was forgetting the has_trivial_xxx traits were renamed/replaced by http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3142.html
> but GCC doesn't implement that yet.
Ok, so they're changing the names, but did they change the meaning?  Do they say wether a compiler's impl of is_trivially* is allowed generate false negatives?

> I'm not sure, but I think std::is_trivially_default_constructible
> should be true for your optional<std::string> union, because although the default constructor is not trivial (in terms of the core language) it doesn't actually call std::string's constructor or any other non-trivial functions.
I think so to.  The frustrating thing is I have to define the ctor/dtor even if they do nothing, but then they appear not to be trivial.


> Again, do-nothing and trivial are not the same thing. And a do-nothing constructor for a struct/class (which default-initiailizes bases and
> members) is not the same as a do-nothing constructor for a union (which does not initialize its members.)
I know.  Theoertically the compiler could go through all base classes and members.  By "do-nothing" constructor I really meant on that generates no code, directly or indirrectly.

> > Is there some proof that doing these things are impossible?
> Not that I know of, but I'd be surprised if is_trivially_xxx or the old has_trivial_xxx can be implemented without compiler magic.
Wow, I'm surprised too! Can you send me a link.  Anything that detects trivial deconstruction seems like it would need magic.  It talks about calling " any operation that is not trivial. "
http://en.cppreference.com/w/cpp/types/is_destructible


What I don't get 100% is:
1) wasn't this stuff supposed to be finished in the standard?
2) are the is_trvial* different from has_trivial* ?
3) does gcc need magic?  Will it do the magic any time soon?

Thanks Jonathan.

Chris


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]