patchGNU Autoconf Archive - Patches: patch #8613, Simplify...

 
 

patch #8613: Simplify _AX_CXX_COMPILE_STDCXX_11_testbody

Submitter:  None
Submitted:  Fri 27 Feb 2015 05:25:53 PM UTC
   
 
Priority:  5 - Normal Status:  Wont Do
Assigned to:  simons Originator Email:  -email is unavailable-
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 28 Aug 2015 11:20:47 PM UTC, comment #5: 

One problem with such static_assert is that __cplusplus doesn't say anything about STL. For example, when Clang 3.2 is used with libstd++ from installation of GCC 4.4. Such STL doesn't support C++11, but it's part of language, and compiler would still report __cplusplus >= 201103L.

Another point, due to a some bug in compiler, some valid C++11 code doesn't compile, even though __cplusplus >= 201103L because developers of the compiler were not aware about that bug. Depending on what exact features of C++11 are used in the project, sometimes such bug isn't harmful, but sometimes it is.
Yes, the project can look at list of features, and enable checks only for those which it uses, but it looks fragile for me. It's easy to forget to update this list in configure.ac, if one sees that project already uses C++11 and therefore assumes that C++11-capable compiler is already required.

Alexey Sokolov <darthgandalf>
Wed 26 Aug 2015 08:27:41 AM UTC, comment #4: 

I tend to agree with Peter Johansson in so far that Autoconf traditionally checks whether certain features work by trying them rather than by looking at the compiler version, etc. The advantage of these practical tests is that they tend to produce reliable results for any kind of compiler, whereas the latter approach works only for compilers that are known to the macro.

Now, I realize that your patch doesn't suffer from that disadvantage, because it uses a well known CPP define rather that a list of known compilers. Still, it's vulnerable to compilers declaring that define incorrectly.

All things considered, I don't quite see what value this refactoring adds. If there were a specific use case that works with the new code but didn't work with the old code, then it would be fine IMHO to put the philosophical issue aside. I'm just not aware of any such concrete benefits from applying this patch?

Peter Simons <simons>
Group administrator
Wed 04 Mar 2015 05:25:53 PM UTC, comment #3: 

From an email from Peter Johansson:


“It's up to the maintainer what he wanna do with the macro, but I just
wanna mention that it's the Autoconf philosophy to rather check features
than version number etc. The latter are proxies of the former, but
unfortunaley they can often be quite inaccurate proxies.”


For what I understand the current code tests for some specific C++ features. My patch changes that to check whether the compiler declares it supports C++11. I think this behaviour is more fit for the macro's name. If the intent is to check for specific features then the macro name should reflect that. Maybe it would be q good idea to create dedicated macros for specific features, and then maybe add a composite macro to check for a set of features.

Although I think this patch still communicates the intent better for this name. :)

Matan Nassau <wilhelmtell>
Wed 04 Mar 2015 10:38:12 AM UTC, comment #2: 

I've added previous contributors of this macro to Cc to solicit comments on the modification.

Peter Simons <simons>
Group administrator
Fri 27 Feb 2015 05:38:19 PM UTC, comment #1: 

Oops, I have a typo in the patch! The static assert string should complain about C++11 compliance, not C++14. Sorry.

Matan Nassau <wilhelmtell>
Fri 27 Feb 2015 05:25:53 PM UTC, original submission:  

IIUC the _AX_CXX_COMPILE_STDCXX_11_testbody macro from m4/am_cxx_compile_stdcxx_11.m4 tests for C++11 conformance via a number of C++11 tricks. I think it would be simpler to just test the __cplusplus macro against its C++11 value.


static_assert(__cplusplus >= 201103L, "C++11?");


I reckon GCC had an issue with this macro for a very long time, but IIUC it's now resolved, and we can rely on it at least for values greater or equal to that of C++11.

I also think this change would make it easier to support checking for newer standards, like checking for the compliance of C++14. Its value for __cplusplus is 201402L, so it would be as simple as changing the static assert for that.

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #33201:  0001-ax_cxx_compile_stdcxx_11-simplify-c-std-check.patch added by None (2KiB - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by darthgandalf (Posted a comment)
  • -email is unavailable- added by simons (Posted a comment)
  • -email is unavailable- added by simons
  • -email is unavailable- added by simons
  • -email is unavailable- added by simons
  • -email is unavailable- added by simons
  • -email is unavailable- added by wilhelmtell (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)
  •  

    Follow 9 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-09-03 simons StatusNeed Info Wont Do
        Open/ClosedOpen Closed
    2015-03-04 simons StatusNone Need Info
        Assigned toNone simons
        Carbon-Copy- Added alexey sokolov <sokolov@google.com>
        Carbon-Copy- Added benjamin kosnik <bkoz@redhat.com>
        Carbon-Copy- Added zack weinberg <zackw@panix.com>
        Carbon-Copy- Added roy stogner <roystgnr@ices.utexas.edu>
    2015-02-27 None Attached File- Added 0001-ax_cxx_compile_stdcxx_11-simplify-c-std-check.patch, #33201

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code