Bug 21385 - __extension__ lost inside template
Summary: __extension__ lost inside template
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.0.0
: P2 minor
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
: 45492 (view as bug list)
Depends on:
Blocks: C++VLA 33485
  Show dependency treegraph
 
Reported: 2005-05-04 18:06 UTC by Jim Rees
Modified: 2021-08-23 11:48 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 2.95.3, 3.0.4, 3.3.3, 3.4.0, 4.0.0, 4.1.0
Last reconfirmed: 2021-08-22 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jim Rees 2005-05-04 18:06:52 UTC
Target: x86_64-suse-linux
Configured with: ../gcc-4.0.0/configure --prefix=/ita3 --enable-languages=c,c++ --with-system-
zlib --enable-__cxa_atexit x86_64-suse-linux : (reconfigured) ../gcc-4.0.0/configure --prefix=/ita3 
--enable-languages=c,c++ --with-system-zlib --enable-__cxa_atexit --disable-checking x86_64-
suse-linux
Thread model: posix
gcc version 4.0.0


template functions appear to erase the effect of the __extension__ keyword inside their definitions, 
causing "-ansi -pedantic" to produce an error instead of a warning.

Compiling the following code with "-ansi -pedantic" produces an error for the line in the template 
function, but not the ordinary function. 

% g++ -c -ansi -pedantic foo.cpp
foo.cpp: In function âint template_function(int) [with T = void]â:
foo.cpp:15:   instantiated from here
foo.cpp:11: error: ISO C++ forbids variable-size array

------------------------------------------------------
int ordinary_function(int dimension)
{
    __extension__ int data[dimension];
    return 0;
}

template<typename T>
int template_function(int dimension)
{
    __extension__ int data[dimension];
    return 0;
}

template int template_function<void>(int);
Comment 1 Drea Pinski 2005-05-04 18:10:03 UTC
Confirmed, not a regression.
Comment 2 Paolo Carlini 2007-09-22 18:08:47 UTC
I'm not sure, but naively appears fixable similarly to the attributes... Jason?
Comment 3 Jason Merrill 2007-09-23 17:49:29 UTC
I don't think implementing this can leverage the attribute work.  I'd probably implement it with a new tree code; the alternative would be a new flag in a lot of places.
Comment 4 Paolo Carlini 2007-09-24 16:46:01 UTC
I see, thanks. Well, if I can bother you a bit more about your very welcome work on attribute aligned, I noticed also PR10179. Thanks again.
Comment 5 Paolo Carlini 2012-05-29 11:52:52 UTC
*** Bug 45492 has been marked as a duplicate of this bug. ***
Comment 6 Paolo Carlini 2012-08-06 17:18:40 UTC
Having a look.
Comment 7 Paolo Carlini 2015-07-10 14:52:12 UTC
Not seriously, for the time being. Unassigning.