[Bug c++/79735] New: C++14: syntax error in attribute deprecated silently ignored

becker.bernd at gmx dot net gcc-bugzilla@gcc.gnu.org
Mon Feb 27 19:46:00 GMT 2017


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

            Bug ID: 79735
           Summary: C++14: syntax error in attribute deprecated silently
                    ignored
           Product: gcc
           Version: 7.0.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: becker.bernd at gmx dot net
  Target Milestone: ---

A malformed deprecated attribute expression is silently ignored. g++ compiles
to a.out and does neither show the deprecated warning nor an error. In the
following code if the closing parenthesis is left out the deprecated warning
disappears, a.out is generated but no error is shown:

#include <iostream>

class [[deprecated("some text")]] Test {
};

int main( int, char**) {
  Test t;
  return 0;
}

Correct output is (German locale):
/local/gcc7/bin/g++ --std=c++14 test.cpp
test.cpp: In Funktion »int main(int, char**)«:
test.cpp:7:8: Warnung: »Test« ist veraltet: some text
[-Wdeprecated-declarations]
   Test t;
        ^
test.cpp:3:35: Anmerkung: hier deklariert
 class [[deprecated("some text")]] Test {
                                   ^~~~

changing line 3 to this ( missing ')' ):
class [[deprecated("some text"]] Test {

results into a successful compile run without warning.

I observed the same problem with gcc 5.4 and 
g++-6 (SUSE Linux) 6.2.1 20160826 [gcc-6-branch revision 239773]


More information about the Gcc-bugs mailing list