Live data from Hacker News

C++ compiler accepts explicit constructor call

connect.microsoft.com

21–30 of 30 posts

Re: C++ compiler accepts explicit constructor call

#21
post #18

Is the implication that other teams are better with standards compliance? Here is a much, much more serious issue. Variable length arrays of C++ types. Totally not in the C++ standard anywhere. Accepted by g++ and clang++, even if I turn on all warnings, and use '-std=c++11', which is supposed to turn off extensions. I have to add -pedantic to finally get a warning. Now, I'm not saying they should break this code, bu…

Standards nonconformance has always been less of a problem when gcc does it. (Of course, part of that is presumably that gcc's nonconformance is generally useful, as in this case...)

FOSS developers like to forget that GCC is also full of language extensions and nonconformance issues.

This is pretty standard type of issues for any ANSI/ISO language regardless of the vendor.

Oh boy the joys of doing C and C++ development across multiple OS in the late 90's with commercial compilers.

Re: C++ compiler accepts explicit constructor call

#22
post #18

Is the implication that other teams are better with standards compliance? Here is a much, much more serious issue. Variable length arrays of C++ types. Totally not in the C++ standard anywhere. Accepted by g++ and clang++, even if I turn on all warnings, and use '-std=c++11', which is supposed to turn off extensions. I have to add -pedantic to finally get a warning. Now, I'm not saying they should break this code, bu…

Standards nonconformance has always been less of a problem when gcc does it. (Of course, part of that is presumably that gcc's nonconformance is generally useful, as in this case...)

The example given in the "story" is useful.

Re: C++ compiler accepts explicit constructor call

#23
post #7
post #5

Unless this breaks valid C++ code, I don't see how they need care too much about fixing it, especially since that would break existing code.

A quote from Stroustrup: "Use of a supplier's language extensions and non-standard-conforming features limits the portability of your code and can prevent you from choosing a new implementation supplier." http://www.stroustrup.com/compilers.html

A sibling thread claims the same syntax is supported by clang, and allowed by gcc using -fpermissive, so it seems like that's not a practical concern in this instance.

Re: C++ compiler accepts explicit constructor call

#24

Is the implication that other teams are better with standards compliance? Here is a much, much more serious issue. Variable length arrays of C++ types. Totally not in the C++ standard anywhere. Accepted by g++ and clang++, even if I turn on all warnings, and use '-std=c++11', which is supposed to turn off extensions. I have to add -pedantic to finally get a warning. Now, I'm not saying they should break this code, bu…

--std=c++11 is not supposed to turn off all extensions, only the extensions that conflict with the standard. The VLA extension only applies to programs that would be malformed according to the standard, so it isn't turned off with -std=c++11. The -pedantic flag is for adhering to the standard exactly.

Re: C++ compiler accepts explicit constructor call

#26
Please don't editorialise submission titles.

Titling a submission "Visual C++ team's attitude to standards compliance" and pointing it at a bug report for some minor non-conforming behaviour tells us nothing useful about the msvc teams attitude to standards. Neither does the brief response from the team on that page. All it says is that there is an issue that they're not going to fix at the moment. Microsoft have a lot of customers, and those customers have a lot of code that they don't want to suddenly break without a good reason.

Do some work. Find or write a useful article investigating the c++ teams attitude to standards compliance and post a link to that. If it compared msvc to other compilers then I'd read it.

Re: C++ compiler accepts explicit constructor call

#27
When I last worked with Windows and would end up on that Microsoft Connect site fairly regularly by Googling, I don't think I ever saw a response that would be satisfactory to the reporter. "Thank for for holding; your call is important to us" or "No", possibly rephrased a few times, was about your lot.

Re: C++ compiler accepts explicit constructor call

#28
post #22
post #18

Earlier quoted context omitted.

Standards nonconformance has always been less of a problem when gcc does it. (Of course, part of that is presumably that gcc's nonconformance is generally useful, as in this case...)

The example given in the "story" is useful.

Not terribly - you can get the same effect with `return Thing()'. This doesn't seem as useful as the similar bug/extension that allows pre-C11 scoped enums (see, e.g., http://stackoverflow.com/questions/441552/scope-resolution-o...).

Re: C++ compiler accepts explicit constructor call

#29
C++ noob here. This reminded me of "Obscure C++ Features" [1] (discussion [2]) - the 'Placement new' feature. Basically, we can allocate memory using malloc and then call the constructor on the allocated memory:

  // Must allocate our own memory
  Test *ptr = (Test *)malloc(sizeof(Test));

  // Use placement new
  new (ptr) Test;

  // Must call the destructor ourselves
  ptr->~Test();

  // Must release the memory ourselves
  free(ptr);

My point is: is possible that the explicit constructor call feature is intended to be used in this use case?

[1]: http://madebyevan.com/obscure-cpp-features/

[2]: https://news.ycombinator.com/item?id=5577631

Re: C++ compiler accepts explicit constructor call

#30
post #21
post #18

Earlier quoted context omitted.

Standards nonconformance has always been less of a problem when gcc does it. (Of course, part of that is presumably that gcc's nonconformance is generally useful, as in this case...)

FOSS developers like to forget that GCC is also full of language extensions and nonconformance issues. This is pretty standard type of issues for any ANSI/ISO language regardless of the vendor. Oh boy the joys of doing C and C++ development across multiple OS in the late 90's with commercial compilers.

Gcc was pretty wild-n-wooly back in the '90s, and seemed to add language extensions left and right, but that attitude changed quite a while ago, and it's very good about standards conformance these days (part of the reason for this, of course is it's no longer so necessary: many of these extensions have picked up by the standard in one form or another).

In my experience, gcc is also significantly better with standards conformance than VC++, either with default settings or with strict warning/conformance options turned on. [I was on a team doing shared g++/vc++ develeopment, and it fell to me to fix all the code checked in by devs using non-standard VC++ extensions... way, way, way too much time... >< ]

Post reply on HN