This is the mail archive of the gcc-bugs@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]

[Bug c++/80243] c++ doesn't allow function to return a struct (or object?) - same thing


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

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Your second example doesn't compile for a very simple reason:

(In reply to Jim Michaels from comment #1)
> #include <string>
> #include <initializer_list>
> typedef struct {std::string s;int i;} Structsb;
> Structsb fn(std::string s1, int i1) {
>     return {s1,i1};
> }
> int main() {}

I'm guessing you didn't mean to put a closing brace here?

> Structsb structsb=fn("string",1);
> return strustsb.i;
> }

Do you see what I mean about reporting bugs every time your code doesn't
compile? This is a simple mistake, not a bug in GCC. Stop assuming everything
is a bug in GCC, which has hundreds of thousands of hours of development and
testing by very talented people who understand C++ very well. If something
trivial like returning a struct didn't work somebody would have noticed before
you did. You're not the only user of GCC.

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